-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwebpack.config.js
111 lines (109 loc) · 2.7 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
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
var path = require('path');
var CleanWebpackPlugin = require('clean-webpack-plugin');
var CopyWebpackPlugin = require('copy-webpack-plugin');
var ExtractWebpackPlugin = require('extract-text-webpack-plugin');
var HtmlWebpackPlugin = require('html-webpack-plugin');
var webpack = require('webpack');
var vendors = [
'react',
'react-chrome-redux',
'react-dom',
'react-redux',
'react-router',
'react-tap-event-plugin',
'redux',
'redux-form',
'redux-logger',
'redux-thunk',
'material-ui',
'superagent',
'keymirror',
'bluebird',
];
var plugins = [
new CleanWebpackPlugin('build'),
new CopyWebpackPlugin([
{ from: path.resolve(__dirname, 'app/manifest.json') },
{ from: path.resolve(__dirname, 'app/shares/images/icon.png') },
]),
new ExtractWebpackPlugin('[name].css', { allChunks: true }),
new HtmlWebpackPlugin({
template: path.resolve(__dirname, 'app/popup/index.html'),
filename: 'popup.html',
chunks: ['vendor', 'popup']
}),
new webpack.optimize.CommonsChunkPlugin('vendor', 'vendor.js'),
new webpack.optimize.OccurenceOrderPlugin()
];
if (process.env.PROD) {
plugins.push(
new webpack.optimize.UglifyJsPlugin({
include: /\.js$/,
compress: {
warnings: false,
dead_code: true,
}
}),
new webpack.DefinePlugin({
'process.env': {
'NODE_ENV': JSON.stringify('production'),
},
})
);
}
module.exports = {
entry: {
background: path.resolve(__dirname, 'app/background/index.js'),
content: path.resolve(__dirname, 'app/content/index.js'),
popup: path.resolve(__dirname, 'app/popup/index.js'),
vendor: vendors,
},
output: {
path: path.resolve(__dirname, 'build'),
filename: '[name].js',
},
module: {
preLoaders: [
{
test: /\.js$/,
exclude: /node_modules/,
loader: 'eslint-loader',
}
],
loaders: [
{
test: /\.js$/,
exclude: /node_modules/,
loader: 'babel-loader',
query: {
presets: ['es2015', 'stage-0', 'react']
}
},
{
test: /\.scss$/,
loader: ExtractWebpackPlugin.extract('style', 'css!sass')
},
{
test: /\.(jpg|git|png)$/,
loader: 'url?limit=8192&name=images/[name].[ext]'
},
{
test: /\.(ttf|eot|svg)(\?v=[0-9]\.[0-9]\.[0-9])?$/,
loader: 'url?limit=8192&name=images/[name].[ext]'
},
{
test: /\.woff(2)?(\?v=[0-9]\.[0-9]\.[0-9])?$/,
loader: 'url?limit=8192&minetype=application/font-woff2&name=images/[name].[ext]'
}
]
},
resolve: {
extensions: ['', '.js']
},
plugins: plugins,
devtool: '',
devServer: {
contentBase: 'build',
host: '0.0.0.0',
},
};