-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwebpack.config.js
60 lines (56 loc) · 1.76 KB
/
webpack.config.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
var _ = require('lodash');
var src_path = 'src';
var app_path = 'app';
var path = require('path');
var webpack = require('webpack');
var pack = require('./package.json');
var port = JSON.stringify(JSON.parse(process.env.PORT || '8081'));
var CommonsChunkPlugin = require('webpack/lib/optimize/CommonsChunkPlugin');
var HtmlWebpackPlugin = require('html-webpack-plugin');
var webpackCommonCfg = require('./webpack.common.config.js')(src_path);
var config = _.assign({},webpackCommonCfg,{
target: 'node',
node: {
__dirname:false
},
externals: {
'sqlite3':'commonjs sqlite3',
},
devServer:{
port:port,
},
devtool: 'eval', //cheap-source-map
debug: true,
output: {
path: path.join(__dirname, 'www', app_path),
filename: '[name].js'
},
plugins:[
new webpack.optimize.DedupePlugin(),
new HtmlWebpackPlugin({
template:path.join(src_path,'indexTpl.html'),
chunksSortMode:function(a,b){
var tulp = ['vendor','common','init'] ;
return -tulp.indexOf(a.names);
}
}),
new webpack.NoErrorsPlugin(),
new webpack.ProvidePlugin({
$: 'jquery',
jQuery: 'jquery',
'window.jQuery': 'jquery',
'_':'lodash',
'window._': 'lodash'
}),
//定义自由变量 development production
new webpack.DefinePlugin({
__DEV__: true,
__APP_PATH__: JSON.stringify(app_path),
__VERSION__: JSON.stringify(pack.version),
'process.env': {
NODE_ENV: JSON.stringify('development')
}
})
],
});
module.exports = config;