-
Notifications
You must be signed in to change notification settings - Fork 0
/
webpack.config.js
78 lines (75 loc) · 2 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
const path = require('path');
const webpack = require('webpack');
const autoprefixer = require('autoprefixer');
const ExtractTextPlugin = require('extract-text-webpack-plugin');
const HtmlWebpackPlugin = require('html-webpack-plugin');
const rootPath = process.cwd();
const webpackConfig = {
context: __dirname,
devtool: 'inline-source-map',
devServer: {
port: 3000,
historyApiFallback: true,
},
entry: [
'whatwg-fetch',
'./app/src/index.jsx',
],
output: {
path: path.join(rootPath, 'dist/'),
filename: '[name]-[hash].js',
publicPath: '/',
},
resolve: {
extensions: ['', '.scss', '.css', '.jsx', '.js', '.json'],
modulesDirectories: [
'node_modules',
path.resolve(__dirname, './node_modules')
]
},
module: {
loaders: [{
test: /(\.js|\.jsx)$/,
exclude: /(node_modules)/,
loader: 'babel',
query: {
presets: ['es2015', 'stage-0', 'react'],
}
}, {
test: /(\.scss|\.css)$/,
loader: ExtractTextPlugin.extract('style', 'css?sourceMap&modules&importLoaders=1&localIdentName=[name]__[local]___[hash:base64:5]!postcss!sass')
}]
},
postcss: [autoprefixer],
plugins: [
new ExtractTextPlugin('styles.css', {
allChunks: true,
}),
new HtmlWebpackPlugin({
template: 'app/index.html',
inject: 'body',
filename: 'index.html'
}),
new webpack.optimize.OccurenceOrderPlugin(),
new webpack.NoErrorsPlugin(),
new webpack.DefinePlugin({
ENVIRONMENT: JSON.stringify(process.env.NODE_ENV || 'development'),
VERSION: JSON.stringify(require('./package.json').version),
}),
]
};
// Environment configuration
if (process.env.NODE_ENV === 'production') {
webpackConfig.plugins.push(new webpack.optimize.UglifyJsPlugin({
compress: {
warnings: false,
dead_code: true,
drop_debugger: true,
drop_console: true,
},
comments: false,
}));
} else {
webpackConfig.devtool = 'eval-source-map';
}
module.exports = webpackConfig;