-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathwebpack.config.js
More file actions
63 lines (59 loc) · 1.63 KB
/
Copy pathwebpack.config.js
File metadata and controls
63 lines (59 loc) · 1.63 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
const debug = process.env.NODE_ENV !== 'production';
const webpack = require('webpack');
const path = require('path');
const ExtractTextPlugin = require('extract-text-webpack-plugin');
const HTMLWebpackPlugin = require('html-webpack-plugin');
const extractPlugin = new ExtractTextPlugin({
filename: 'styles/main.css',
});
module.exports = {
context: path.join(__dirname, ''),
devtool: debug ? '#inline-source-map' : '#nosources-source-map',
entry: ['babel-polyfill', './src/main.js'],
module: {
loaders: [{
test: /\.jsx?$/,
exclude: /(node_modules|bower_components)/,
loader: 'babel-loader',
query: {
presets: ['react', 'es2015', 'stage-0'],
plugins: ['react-html-attrs', 'transform-decorators-legacy', 'transform-class-properties'],
},
}, {
test: /\.css$/,
loader: extractPlugin.extract({
use: ['css-loader'],
}),
}, {
test: /\.html$/,
loader: 'html-loader',
}],
},
output: {
path: `${__dirname}/dist`,
filename: 'js/scripts.min.js',
publicPath: '/',
},
plugins: [
extractPlugin,
new HTMLWebpackPlugin({
template: 'src/index.html',
}), ...(debug ? [] : [
new webpack.optimize.OccurrenceOrderPlugin(),
new webpack.optimize.UglifyJsPlugin({
mangle: false,
sourcemap: false,
}),
new webpack.DefinePlugin({
'process.env': {
NODE_ENV: JSON.stringify('production'),
},
}),
])],
devServer: {
contentBase: './dist', // Relative directory for base of server
port: 8080, // Port Number
host: '0.0.0.0',
historyApiFallback: true,
},
};