在我的远程服务器上(Ubuntu 14.04 x64),每当我尝试压缩我的捆绑包时,该进程会简单地返回"Killed"。当我不压缩时,它就很好。有人遇到过这种情况吗?当我在本地的Mac上执行此操作时,一切正常(虽然我刚刚测试了一下,它需要1.4分钟)。这是我的webpack.config:
var webpack = require('webpack');
function makeConfig(opts) {
var config = {
entry: {
app: ['./public/scripts/main.js'],
vendor: ['lodash', 'react', 'react/lib/ReactCSSTransitionGroup', 'react-router', 'reqwest', 'd3']
},
stats: {
colors: true,
reasons: true
},
output: {
devtool: (opts.env === 'dev' ? '#eval-source-map' : ''),
path: 'dist/scripts',
filename: '[name].bundle.js'
},
plugins: [
new webpack.DefinePlugin({
ENV: opts.env
}),
new webpack.optimize.CommonsChunkPlugin('vendor.bundle.js')
],
module: {
loaders: [
{ test: /\.jsx?$/, loader: 'jsx-loader' }
]
}
};
if(opts.env === 'prod') {
config.plugins.push(
new webpack.optimize.UglifyJsPlugin(),
new webpack.optimize.DedupePlugin()
);
}
return config;
}
module.exports = makeConfig;
然后使用 gulp 这样调用它:
gulp.task('webpack', ['cleanScripts'], function(done) {
webpack(webpackConfig, function(err, stats) {
if(err) {
console.error(err);
throw new gutil.PluginError('webpack', err);
}
else {
done();
}
});
});