-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathwebpack.config.js
More file actions
87 lines (81 loc) · 2.42 KB
/
webpack.config.js
File metadata and controls
87 lines (81 loc) · 2.42 KB
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
/* eslint-disable */
var path = require('path');
var fs = require('fs');
var webpack = require('webpack');
var WebpackNotifierPlugin = require('webpack-notifier');
var autoprefixer = require('autoprefixer');
var HtmlWebpackPlugin = require('html-webpack-plugin');
var rootPath = path.join(__dirname, './client');
var env = process.env.NODE_ENV || 'development';
module.exports = {
devtool: env === 'development' ? 'eval-source-map' : 'source-map',
devServer: {
headers: { 'Access-Control-Allow-Origin': '*' },
noInfo: true
},
stats: {
colors: true
},
entry: {
app: [
env === 'development' && 'react-hot-loader/patch',
env === 'development' && 'webpack-hot-middleware/client',
'./client/index'
].filter(Boolean)
},
output: {
path: path.join(__dirname, 'build'),
publicPath: '/',
filename: '[name].js'
},
module: {
loaders: [
{
test: /\.jsx?$/,
include: [rootPath],
exclude: /node_modules/,
loader: 'babel'
},
{ test: /.*\.scss$/, loader: 'style!css?modules!postcss!sass' },
{ test: /.*\.css$/, loader: 'style!css?modules!postcss' },
{ test: /\.png/, loader: "file-loader?mimetype=image/png" },
{ test: /\.jpg/, loader: "file" },
{ test: /\.gif/, loader: "file" },
{ test: /\.woff2?(\?v=[0-9]\.[0-9]\.[0-9])?$/, loader: "file-loader?mimetype=application/font-woff" },
{ test: /\.(ttf|eot|svg)(\?v=[0-9]\.[0-9]\.[0-9])?$/, loader: "file-loader" }
]
},
postcss: function() {
return [autoprefixer({ browsers: ['last 2 versions'] })];
},
resolve: {
root: rootPath,
alias: {
db: path.join(__dirname, './db.js')
},
extensions: ['', '.js', '.jsx', '.json', '.css', '.scss']
},
plugins: [
// Prevent showing lint errors
new webpack.NoErrorsPlugin(),
new webpack.optimize.OccurenceOrderPlugin(),
env === 'development' && new webpack.HotModuleReplacementPlugin(),
env !== 'development' && new webpack.optimize.UglifyJsPlugin({
compress: {
warnings: false
}
}),
new WebpackNotifierPlugin(),
new HtmlWebpackPlugin({
template: "./client/assets/index.template.html",
environment: env
}),
new webpack.DefinePlugin({
'process.env': {
// Useful to reduce the size of client-side libraries, e.g. react
NODE_ENV: JSON.stringify(env)
}
}),
].filter(Boolean)
};
/* eslint-enable */