1
我有一个反应应用程序,我正在开发,我对webpack不太熟悉。我用一些自定义JavaScript实现了引导主题,当我在我的index.html
正文中手动链接所有脚本时,它工作正常。Webpack:如何将JS文件的文件夹添加到打包程序
黑客方法非常混乱,稍后在缩小所有脚本时会减少控制权。
我所有的脚本都位于src
中的一个名为vendor
的文件夹中。如何将vendor
文件夹中的所有文件与webpack捆绑的其他内容捆绑在一起?
这是我的WebPack文件以供参考:
const debug = process.env.NODE_ENV !== "production"
const webpack = require('webpack')
const ExtractTextPlugin = require("extract-text-webpack-plugin")
const path = require('path')
const loaders = require('./webpack.loaders')
module.exports = {
context: path.resolve(__dirname, "src"),
resolve: {
root: [ path.resolve(__dirname, "src")],
extensions: ['', '.js', '.jsx']
},
devtool: debug ? "inline-sourcemap" : null,
entry: "./js/client.js",
module: {
loaders: loaders.concat([
{
test: /\.js?$/,
exclude: /(node_modules|bower_components)/,
loader: 'babel-loader',
query: {
presets: ['react', 'es2015', 'stage-0'],
plugins: ['react-html-attrs', 'transform-class-properties', 'transform-decorators-legacy']
}
}
])
},
output: {
path: __dirname + "/src/",
filename: "client.min.js"
},
plugins:
debug ? [] : [
new webpack.optimize.DedupePlugin(),
new webpack.optimize.OccurenceOrderPlugin(),
new webpack.optimize.UglifyJsPlugin({ mangle: false, sourcemap: false })
]
}