我在包裝我的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應用程序。 –