This repository has been archived by the owner on Mar 16, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 3
/
webpack.config.js
91 lines (82 loc) · 2.15 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
const path = require('path');
const webpack = require('webpack');
const ExtractTextPlugin = require('extract-text-webpack-plugin');
const cssnext = require('postcss-cssnext');
const nested = require('postcss-nested');
const atImport = require('postcss-import');
const cssvariables = require('postcss-css-variables');
const root = (...args) => path.join(__dirname, 'src', ...args);
const webpackConfig = {
name : 'client',
target : 'web',
devtool : 'source-map',
entry : root('app.js'),
output : {
filename : 'bundle.js',
path : root('..', 'dist'),
publicPath: '/dist/'
},
resolve : {
root : root(),
extensions: ['', '.js', '.jsx', '.json'],
alias : {
'react' : 'react-lite',
'react-dom': 'react-lite'
}
},
module : {
loaders: [
{
test : /\.jsx?/,
loader : 'babel',
exclude: /node_modules/,
query : {
cacheDirectory: true,
plugins: [
'transform-runtime',
'transform-flow-strip-types'
],
presets: ['es2015', 'react', 'stage-0']
}
},
{
test: /\.json/,
loader: 'json'
},
{
test: /\.css/,
loader: ExtractTextPlugin.extract('css?sourceMap&minimize&-url!postcss')
}
]
},
plugins: [
new webpack.optimize.OccurrenceOrderPlugin(),
new ExtractTextPlugin('styles.css')
],
postcss: webpack => [
atImport({
paths: [
root('css'),
root('..', 'node_modules')
],
addDependencyTo: webpack
}),
nested,
cssvariables(),
cssnext({
browsers: '> 0%'
}),
]
};
if (process.env.NODE_ENV === 'production') {
console.log('[Production build loaded]');
webpackConfig.devtool = null;
webpackConfig.plugins.push(new webpack.DefinePlugin({
'process.env': {
NODE_ENV: JSON.stringify('production')
}
}));
webpackConfig.plugins.push(new webpack.optimize.DedupePlugin());
webpackConfig.plugins.push(new webpack.optimize.UglifyJsPlugin({ sourceMap: false }));
}
module.exports = webpackConfig;