-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwebpack.config.js
82 lines (75 loc) · 2.19 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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
const path = require('path')
const webpack = require('webpack')
const ExtractTextPlugin = require('extract-text-webpack-plugin')
var production = process.argv.reduce(function(p, c){return p || c == '-p'}, false)
var config = {
context: path.join(__dirname, '/src/main/jsx'),
entry: {
app:'./app.jsx',
vendor: [
'babel-polyfill',
'react', 'react-dom'
],
},
devtool: production ? 'cheap-source-map' : 'source-map',
output: {
path: path.resolve(__dirname, 'target/' + process.env.WAR_NAME + '/assets'),
filename: path.normalize('[name].js'),
publicPath: 'assets/'
},
module: {
loaders: [
{
test: /\.less$|\.css$/,
loader: production ? ExtractTextPlugin.extract('css?sourceMap!less?sourceMap'): 'style-loader!css?sourceMap!less?sourceMap'
},
{
test: /\.jsx$/,
exclude: /(node_modules)/,
loaders: production ? ['babel-loader?presets[]=react,presets[]=es2015,presets[]=stage-2'] : ['react-hot', 'babel-loader?presets[]=react,presets[]=es2015,presets[]=stage-2']
},
{
test: /\.json$/,
exclude: /(node_modules)/,
loader: 'json'
}
]
},
plugins: [
new ExtractTextPlugin(path.normalize('[name].css')),
new webpack.optimize.CommonsChunkPlugin("vendor", 'vendor.js', Infinity)
],
stats:{
children: false
},
devServer: {
quiet: false,
noInfo: false,
stats:{
assets: false,
colors: false,
version: true,
hash: true,
timings: true,
chunks: true,
chunkModules: false,
children: false
}
}
}
if(production){
config.plugins.push(new webpack.DefinePlugin({
'process.env': {
'NODE_ENV': JSON.stringify('production')
}
})
)
config.plugins.push(new webpack.optimize.UglifyJsPlugin(
{
compress: {
warnings: false
}
})
)
}
module.exports = config