我在包装我的Webpack ReactJS应用程序时发现了许多技巧。不幸的是,文件大小仍然是3MB。我究竟做错了什么?为什么我的Webpack ReactJS应用程序如此之大?
这里是我的WebPack配置文件:
var path = require('path')
var webpack = require('webpack')
module.exports = {
devtool: 'cheap-module-eval-source-map',
entry: [
'webpack-hot-middleware/client',
'./index'
],
output: {
path: path.join(__dirname, 'dist'),
filename: 'bundle-webpack.js',
publicPath: './'
},
plugins: [
new webpack.optimize.OccurenceOrderPlugin(),
new webpack.HotModuleReplacementPlugin(),
new webpack.NoErrorsPlugin(),
new webpack.DefinePlugin({
'process.env.NODE_ENV': JSON.stringify('production')
}),
new webpack.optimize.UglifyJsPlugin({
compress: {
screw_ie8: true,
warnings: false
}
})
],
module: {
loaders: [
{
test: /\.js$/,
loaders: [ 'babel' ],
exclude: /node_modules/,
include: __dirname
},
{
test: /\.css$/,
loader: "style-loader!css-loader"
},
{test: /node_modules\/react-chatview/, loader: 'babel' }
]
}
}
任何帮助将不胜感激!
我使用以下命令将它打包:
> NODE_ENV=production webpack -p
我得到以下输出:
bundle-webpack.js 3.1 MB 0 [emitted] main
最佳,
亚伦
感谢您的回复David!我跟着你没有运气给我的指南。以下是我现在得到的输出。 捆prod.js 349 KB 0发出]主 bundle-prod.js.map 3.13 MB 0 [发出]主 [0]的多主28个字节{0} [内置] + 629个隐藏模块 我真的不明白我错过了什么。我的应用程序是一个非常简单的ReactJS + Redux应用程序。 –