This repository has been archived by the owner on Feb 23, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
/
webpack.config.js
69 lines (66 loc) · 1.48 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
const webpack = require('webpack');
const ExtractTextPlugin = require('extract-text-webpack-plugin');
const HtmlWebpackPlugin = require('html-webpack-plugin');
const CopyWebpackPlugin = require('copy-webpack-plugin');
var plugins = [
new ExtractTextPlugin('./css/bundle.css', { allChunks: true }),
new HtmlWebpackPlugin({
template: __dirname + '/client/src/index.html',
filename: 'index.html',
inject: 'body'
}),
new CopyWebpackPlugin([{
from: 'client/src/assets',
to: 'assets'
}])
];
if (process.env.NODE_ENV === "production") {
plugins.push(
new webpack.DefinePlugin({
"process.env": {
"NODE_ENV": JSON.stringify("production")
}
}),
new webpack.optimize.UglifyJsPlugin({
compress:{
warnings: true
}
})
);
}
module.exports = {
entry: __dirname + '/client/src/js/index.jsx',
output: {
path: './client/build',
filename: './js/bundle.js',
},
devtool: 'source-map',
module: {
loaders: [
{
test: /\.jsx?$/,
exclude: /(node_modules)/,
loader: 'babel',
include: __dirname + '/client/src/js',
query: {
presets: ['es2015', 'react']
}
},
{
test: /\.css$/,
loader: ExtractTextPlugin.extract('style-loader', 'css-loader')
},
{
test: /\.json$/,
loader: 'json'
}
]
},
externals: {
'fs': 'fs'
},
resolve: {
extensions: ['', '.js', '.jsx', '.es6']
},
plugins: plugins
}