-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathwebpack.config.js
57 lines (54 loc) · 1.81 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
var path = require('path')
var webpack = require('webpack')
var HtmlWebpackPlugin = require('html-webpack-plugin')
var ExtractTextPlugin = require("extract-text-webpack-plugin");
module.exports = {
context: path.join(__dirname,'./src/entries'),
entry: {
main : './main.js',
commons : ['react','react-dom']
},
output: {
path: path.join(__dirname,'dist'),
// publicPath: "/bundles/",
filename: "[name].[hash].bundle.js",
chunkFilename: "[id].[hash].chunk.js"
},
module: {
loaders: [
{ test : /\.less$/, loader : ExtractTextPlugin.extract('style-loader','css-loader!postcss-loader!less-loader',{publicPath : ''}) },
{ test : /\.css$/, loader : ExtractTextPlugin.extract('style-loader','css-loader',{publicPath : ''}) },
// { test: /\.jsx?$/, loader : 'uglify-loader!babel-loader?presets[]=react,presets[]=es2015' , exclude: /(node_modules|bower_components)/},
{ test : /\.jsx?$/ ,loader : 'babel' , exclude: /(node_modules|bower_components)/},
{ test : /\.(png|jpg|jpeg|gif)$/, loader: "url-loader?limit=30000" },
{ test : /\.(svg|ttf|eot|svg|woff(\(?2\)?)?)(\?[a-zA-Z_0-9.=&]*)?(#[a-zA-Z_0-9.=&]*)?$/, loader : "file-loader"}
]
},
resolve : {
root : path.resolve('./src')
},
postcss: function () {
return [require('autoprefixer'),require('postcss-filter-gradient')];
},
plugins : [
new webpack.optimize.UglifyJsPlugin({
compressor: {
warnings: false
},
mangle: {
except: ['$super', '$', 'exports', 'require']
}
}),
new webpack.DefinePlugin({
"process.env" : {
NODE_ENV : JSON.stringify("production")
}
}),
new webpack.optimize.CommonsChunkPlugin("commons", "[name].[hash].bundle.js"),
new ExtractTextPlugin("[name].[hash].bundle.css",{allChunks: true}),
new HtmlWebpackPlugin({
template : path.join(__dirname,'src/index.html'),
inject: true
})
]
};