const fs = require('fs');
const webpack = require('webpack');
const path = require('path');
const nodeModules = {};
fs.readdirSync('node_modules').filter(x => {
return x.indexOf('.bin') === -1;
}).forEach(mod => {
nodeModules[mod] = `commonjs ${mod}`;
});
module.exports = {
entry: './index.js',
target: 'node',
output: {
path: path.resolve(__dirname, 'dist'),
filename: 'index.bundle.js'
},
plugins: [
new webpack.optimize.UglifyJsPlugin({
compress: {
warnings: false
}
})
],
externals: nodeModules
};
转载于:https://my.oschina.net/flywuya/blog/1517593