-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwebpack.config.js
86 lines (77 loc) · 1.88 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
import webpack from 'webpack'
import path from 'path'
const debug = process.env.NODE_ENV !== 'production'
const devtool = debug && 'eval'
const entries = {
bundle: ['./src/index.js', './src/index.html'],
}
const output = {
path: path.join(__dirname, '/build'),
filename: '[name].js',
publicPath: '/',
pathinfo: debug,
}
const loaders = [
{
test: /\.jsx?$/,
loader: debug ? 'react-hot!babel?stage=0&cacheDirectory' : 'babel?stage=0',
exclude: /node_modules/,
},
{test: /\.json$/, loader: 'json', exclude: /node_modules/},
{test: /\.css$/, loader: 'style!css!postcss', exclude: /node_modules/},
{test: /\.svg$/, include: /assets/, loader: 'raw'}, // Embed SVG icons
{
test: /.(png|jpg|svg)$/,
loader: 'url?limit=5000&name=images/[name].[ext]',
exclude: [/node_modules/, /assets/],
},
{test: /\.(eot|ttf|woff2?)$/, loader: 'file?name=fonts/[name].[ext]'},
{test: /\.html$/, loader: 'file?name=[name].[ext]'},
]
const plugins = [
new webpack.PrefetchPlugin('react'),
new webpack.DefinePlugin({
'process.env': {
GOOGLE_ANALYTICS_ID: JSON.stringify(process.env.GOOGLE_ANALYTICS_ID),
},
}),
]
const resolve = {
extensions: ['', '.js', '.jsx', '.json', '.css', '.styl'],
modulesDirectories: ['node_modules', './src'],
alias: {},
}
const postcss = [
require('postcss-nested'),
require('postcss-calc'),
require('postcss-color-function')(),
require('postcss-easings'),
require('postcss-focus'),
require('autoprefixer-core')(),
]
// Minification
if (!debug) {
plugins.push(
new webpack.optimize.OccurenceOrderPlugin(),
new webpack.optimize.UglifyJsPlugin({
sourceMap: false,
compress: {
drop_console: true,
screw_ie8: true,
warnings: false,
},
})
)
}
module.exports = {
debug,
devtool,
entry: entries,
output,
module: {
loaders,
},
postcss,
plugins,
resolve,
}