-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathwebpack.config.js
78 lines (73 loc) · 1.83 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
/**
* Created by yatessss on 16/11/18.
*/
var path = require('path');
var webpack = require('webpack');
var nodeEnv
console.log(process.env.NODE_ENV)
if (process.env.NODE_ENV === 'dev') {
nodeEnv = {
app: './app/main.dev.js',
vendors: ['react']
}
} else {
nodeEnv = {
app: './app/main.js',
vendors: ['react']
}
}
var config = {
entry: nodeEnv,
output: {
path: path.resolve(__dirname, 'build'),
filename: 'app.js'
},
module: {
loaders: [{
test: /\.jsx?$/,
loader: 'babel',
exclude: /node_modules/
}, {
test: /\.css$/, // Only .css files
loader: "style-loader!css-loader!postcss-loader"
}, {
test: /\.scss$/,
loader: 'style!css!postcss-loader!sass'
}, {
test: /\.(png|jpg)$/,
loader: 'url?limit=25000'
}, {
test: /\.woff$/,
loader: 'url?limit=100000'
}]
},
postcss: [require('postcss-px2rem')({
baseDpr: 1, // base device pixel ratio (default: 2)
threeVersion: false, // whether to generate @1x, @2x and @3x version (default: false)
remVersion: true, // whether to generate rem version (default: true)
remUnit: 37.5, // rem unit value (default: 75)
remPrecision: 3 // rem precision (default: 6)
})],
autoprefixer: {
browsers: ["Android >= 2.3", "iOS >= 4"], //, "ChromeAndroid > 1%"
cascade: false // 不美化输出 css
},
devServer: {
inline: true
},
plugins: [
new webpack.HotModuleReplacementPlugin(),
new webpack.optimize.CommonsChunkPlugin('vendors', 'vendors.js', Infinity),
// new webpack.DefinePlugin({
// 'process.env': {
// NODE_ENV: JSON.stringify('production')
// }
// }),
new webpack.optimize.UglifyJsPlugin({
compress: {
warnings: false
}
})
]
};
module.exports = config;