-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathwebpack.config.js
More file actions
68 lines (65 loc) · 2.05 KB
/
webpack.config.js
File metadata and controls
68 lines (65 loc) · 2.05 KB
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
var path = require('path')
var webpack = require('webpack')
var HtmlWebpackPlugin = require('html-webpack-plugin')
var ExtractTextPlugin = require('extract-text-webpack-plugin')
var es3ifyPlugin = require('es3ify-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].[chunkhash].chunk.js'
},
externals : {
'react' : 'React',
'react-dom' : 'ReactDOM'
},
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 es3ifyPlugin(),
new webpack.optimize.UglifyJsPlugin({
compressor: {
warnings: false,
properties : false
},
mangle: {
except: ['$super', '$', 'exports', 'require'],
},
output : {
keep_quoted_props: true
}
}),
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/dist.html'),
inject: true,
chunks : ['commons','main']
})
]
}