-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathwebpack.config.js
More file actions
58 lines (54 loc) · 1.72 KB
/
webpack.config.js
File metadata and controls
58 lines (54 loc) · 1.72 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
/* global __dirname */
var path = require('path');
var isProd = process.env.NODE_ENV == 'production';
var webpack = require('webpack');
var CopyWebpackPlugin = require('copy-webpack-plugin');
var ExtractTextPlugin = require("extract-text-webpack-plugin");
var dir_html = path.resolve(__dirname, 'client/html');
var dir_build = path.resolve(__dirname, 'client/build');
var dir_client = path.resolve(__dirname,'client');
module.exports = {
entry: path.resolve(dir_client, 'index.js'),
output: {
path: dir_build,
filename: 'bundle.js',
publicPath: '/static/'
},
devServer: {
contentBase: dir_build,
},
module: {
loaders: [
{
loader: 'react-hot',
test: /\.js$/,
},
{
loader: 'babel-loader',
test: /\.js$/,
query: {
presets: ['es2015', 'react'],
},
},
{ test: /\.css$/, loader: ExtractTextPlugin.extract("style-loader", "css-loader") },
{ test: /\.(png|woff|woff2|eot|ttf|svg)$/, loader: 'url-loader?limit=100000' }
]
},
plugins: [
isProd ? new webpack.optimize.UglifyJsPlugin({minimize: true}) : function () {},
// Simply copies the files over
// new CopyWebpackPlugin([
// { from: dir_html } // to: output.path
// ]),
// Separate css file from bundle.js
new ExtractTextPlugin("bundle.css"),
// Avoid publishing files when compilation fails
new webpack.NoErrorsPlugin()
],
stats: {
// Nice colored output
colors: true
},
// Create Sourcemaps for the bundle
devtool: 'source-map',
};