由於我已經有jQuery
和React
的縮小版本,所以我不需要它們的uglification。我想要的是bundle.js
包含完全相同的jquery.min.js
和react.min.js
。基本上,我期望webpack
只是將它們連接起來。還有一件事,我不想externals
。我怎樣才能實現它?如何在webpack中排除* .min.js的uglification
const webpack = require("webpack");
module.exports = {
"entry": ["./src/main/index.js"],
"output": {
"filename": "[name].js",
"libraryTarget": "umd"
},
"module": {
"rules": [
{
"test": /\.(js|jsx)$/,
"exclude": /node_modules/,
"loader": "babel-loader",
"options": {
"presets": ["es2015", "react"]
}
}
]
},
"resolve": {
"alias": {
"jquery": "jquery/dist/jquery.min.js",
"React": "react/dist/react.min.js",
"ReactDom": "react-dom/dist/react-dom.min.js"
}
},
"plugins": [
new webpack.optimize.UglifyJsPlugin({
"test": /\.(js)$/,
"exclude": /node_modules/,
"compress": true
}),
]
}
嘗試排除像這樣'exclude:/ \ .min \ .js $ /' – Thaadikkaaran
webpack.optimize.uglifyjsplugin的實現沒有排除。見https://github.com/webpack/webpack/blob/master/lib/optimize/UglifyJsPlugin.js – WooD