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 })
]
}