Webpack minification -p错误
我使用webpacktesting我的生产JavaScript与minifcation。 它工作正常unminified,但是当我添加-p
标志:
NODE_ENV=production ./node_modules/webpack/bin/webpack.js -p --progress --colors
我收到警告,并有JavaScript错误。 出现它正在删除它不应该的东西。 无法弄清楚为什么。
警告:
WARNING in client.js from UglifyJs Side effects in initialization of unused variable React [./~/fluxible/lib/Fluxible.js:12,0] Dropping unused function $$$enumerator$$makeSettledResult [./~/fluxible/~/es6-promise/dist/es6-promise.js:361,0] Side effects in initialization of unused variable $$utils$$now [./~/fluxible/~/es6-promise/dist/es6-promise.js:35,0] Side effects in initialization of unused variable $$utils$$o_create [./~/fluxible/~/es6-promise/dist/es6-promise.js:38,0] Dropping unused variable internals [./~/react-router/~/qs/lib/utils.js:6,0] Dropping side-effect-free statement [./~/fluxible/addons/provideContext.js:6,0] Side effects in initialization of unused variable Action [./~/fluxible/~/dispatchr/lib/Dispatcher.js:7,0] Dropping unused variable internals [./~/react-router/~/qs/lib/index.js:9,0]
这是我的webpack.config.js
var ExtractTextPlugin = require('extract-text-webpack-plugin'); var path = require('path'); module.exports = { entry: [ './client.js', ], output: { path: path.join(__dirname, 'assets'), filename: 'client.js', publicPath: '/assets', }, plugins: [ new ExtractTextPlugin('styles.css'), ], module: { loaders: [ { test: /\.(js|jsx)$/, exclude: /node_modules\/(?!react-router)/, loader: 'react-hot!babel-loader?stage=0' }, { test: /\.scss$/, loader: ExtractTextPlugin.extract( // activate source maps via loader query 'css?sourceMap!' + 'sass?sourceMap' ) }, // bootstrap { test: /\.(ttf|eot|svg)(\?v=[0-9]\.[0-9]\.[0-9])?$/, loader: 'url-loader?limit=10000&mimetype=application/font-eot', }, { test: /\.(woff)(\?v=[0-9]\.[0-9]\.[0-9])?$/, loader: 'url-loader?limit=10000&mimetype=application/font-woff', }, { test: /\.(woff2)(\?v=[0-9]\.[0-9]\.[0-9])?$/, loader: 'url-loader?limit=10000&mimetype=application/font-woff2', }, { test: /\.js$/, include: /node_modules\/bootstrap/, loader: 'imports?jQuery=jquery' }, ], }, };
谢谢
您看到的警告是由于加载程序正在parsing您的node_module依赖关系。 由于唯一你排除的是无论匹配/ node_modules /(?! react-router)/
不要使用模块加载器的exclude
选项,只尝试用白名单列出要用include
加载的模块
exclude
应该用来排除例外情况,尽可能地使用include
来匹配目录
- 在Azure移动服务中更改节点JS版本
- 在使用Google Closure Compiler,webpack和Firebase JS SDK编译js时出现JSC_NON_GLOBAL_DEFINE_INIT_ERROR
- 在javascript中从二维数组中select一个二维数组
- 如何在OSX Yosemite上使用node.js 0.12正确安装node-inspector?
- JavaScript – 编译错误的序列
- Cron工作在Meteor
- 如何asynchronous并行多个app.use调用?
- 在Express 3.x和Jade模板中使用NodeJS可以重新渲染一个以前渲染列表的项目吗?
- 节点js护照redirect结果在404