-
Notifications
You must be signed in to change notification settings - Fork 24
/
Copy pathwebpack.config.js
73 lines (71 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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
const path = require('path');
const HtmlWebpackPlugin = require('html-webpack-plugin');
const webpack = require('webpack');
module.exports = env => {
const isProduction = plugin => (
env.prod ? plugin : undefined
);
const removeEmpty = array => array.filter(p => Boolean(p));
return {
context: __dirname,
entry: {
app: path.join(__dirname, './src/youtube.jsx'),
vendor: ['react', 'react-dom', 'react-router']
},
output: {
path: path.join(__dirname, 'app', 'javascripts'),
publicPath: path.join('app', 'javascripts/'),
filename: '[name].js'
},
module: {
loaders: [
{
test: [/\.jsx?$/, /\.js?$/],
exclude: /(node_modules)/,
loader: 'babel-loader',
query: {
presets: ['env', 'react'],
cacheDirectory: true
}
}
]
},
devtool: 'source-map',
resolve: {
extensions: ['.js', '.jsx', '*'],
modules: [
path.resolve(__dirname, 'src'),
path.resolve(__dirname, 'node_modules')
]
},
plugins: removeEmpty([
new webpack.optimize.CommonsChunkPlugin({
name: 'vendor',
minChunks: Infinity,
filename: '[name].js'
}),
new HtmlWebpackPlugin({
template: path.join(__dirname, 'template.html'),
filename: '../../index.html',
inject: 'body'
}),
isProduction(new webpack.DefinePlugin({
'process.env': {
NODE_ENV: JSON.stringify('production')
}
})),
isProduction(new webpack.optimize.UglifyJsPlugin({
compress: {
screw_ie8: true,
warnings: false,
unused: true,
dead_code: true
},
output: {
comments: false
},
sourceMap: false
}))
])
};
};