-
Notifications
You must be signed in to change notification settings - Fork 4
/
webpack.config.babel.js
91 lines (88 loc) · 2.48 KB
/
webpack.config.babel.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
import path from 'path'
import webpack from 'webpack'
import ExtractTextPlugin from 'extract-text-webpack-plugin'
const PROD = (process.env.NODE_ENV === 'production')
const entryDevelopment = [
"webpack-dev-server/client?/", // Inlines auto-refresh code
"webpack/hot/dev-server", // Hot Module Replacement
]
export default {
entry: {
app: ["./main.js"].concat(PROD ? [] : entryDevelopment),
},
output: {
path: path.resolve('./dist'),
filename: '[name].js',
},
devtool: PROD ? undefined : '#eval-source-map',
devServer: {
hot: true,
contentBase: path.resolve('./static'),
host: "0.0.0.0",
},
plugins: [
new webpack.DefinePlugin({
'process.env.NODE_ENV': JSON.stringify(process.env.NODE_ENV || 'development'),
}),
].concat(PROD ? [
new webpack.NoErrorsPlugin(),
new ExtractTextPlugin('style.css', { allChunks: true }),
new webpack.optimize.DedupePlugin(),
new webpack.optimize.OccurenceOrderPlugin(),
new webpack.optimize.UglifyJsPlugin({
compress: {
warnings: false,
pure_funcs: ['console.log', 'console.info'],
unused: true,
},
mangle: {
except: ['DevTools'],
},
}),
] : [
new webpack.NamedModulesPlugin(),
new webpack.HotModuleReplacementPlugin(),
]),
resolve: {
root: [path.resolve('./components')],
moduleDirectories: [path.resolve('./node_modules')],
},
module: {
loaders: [
{
test: /\.js$/,
loaders: PROD ? ['babel'] : ['react-hot', 'babel'],
exclude: [path.resolve('./node_modules')],
include: [path.resolve('./')],
},
{
test: /\.css$/,
loaders: PROD ? undefined : [
'style-loader',
'css-loader?modules&importLoaders=1&localIdentName=[path][local]',
'postcss-loader',
],
loader: PROD ? ExtractTextPlugin.extract(
'style-loader',
[
'css-loader?modules&importLoaders=1&localIdentName=[hash:base64:5]',
'postcss-loader',
]
) : undefined,
},
{
test: /\.(eot|svg|ttf|woff|woff2)$/,
loader: 'file?name=static/fonts/[name].[ext]',
},
{
test: /\.json$/,
loaders: ['json'],
},
{ test: /\.(glsl|frag|vert)$/, loader: 'raw', exclude: /node_modules/ },
{ test: /\.(glsl|frag|vert)$/, loader: 'glslify', exclude: /node_modules/ },
],
},
postcss: [
require('postcss-cssnext'),
],
}