-
Notifications
You must be signed in to change notification settings - Fork 2
/
webpack.config.babel.js
85 lines (74 loc) · 1.78 KB
/
webpack.config.babel.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
79
80
81
82
83
84
85
const webpack = require('webpack');
const HtmlWebpackPlugin = require('html-webpack-plugin');
const autoprefixer = require('autoprefixer');
const path = require('path');
const config = {
context: path.join(__dirname, 'app'),
entry: [
'./index.js'
],
output: {
path: path.join(__dirname, 'dist'),
filename: 'bundle.js'
},
module: {
loaders: [
{
test: /\.(js|jsx)$/,
loader: 'babel-loader',
exclude: /node_modules/
},
{
test: /\.css$/,
loader: 'style-loader!css-loader!postcss-loader'
},
{
test: /\.(scss|sass)$/,
loader: 'style-loader!css-loader!sass-loader!postcss-loader'
},
{
test: /\.(woff|woff2|otf|ttf)$/,
loader: 'file-loader?name=fonts/[name].[ext]'
},
{
test: /\.(png|jpg|gif|svg)$/,
loader: 'url-loader?prefix=image/&limit=5000&context=./app/images'
}, {
test: /\.mp4$/,
loader: 'url-loader?limit=10000&mimetype=video/mp4'
}
]
},
postcss() {
return [autoprefixer];
},
resolve: {
extensions: ['', '.js', '.jsx', '.css', '.scss']
},
plugins: [
new HtmlWebpackPlugin({
template: 'index.html',
inject: 'body',
filename: 'index.html'
}),
new webpack.optimize.OccurenceOrderPlugin(),
new webpack.HotModuleReplacementPlugin(),
new webpack.NoErrorsPlugin(),
new webpack.DefinePlugin({})
]
};
// Environment configuration
if (process.env.NODE_ENV === 'production') {
config.plugins.push(new webpack.optimize.UglifyJsPlugin({
compress: {
warnings: false,
dead_code: true,
drop_debugger: true,
drop_console: true
},
comments: false
}));
} else {
config.devtool = 'eval-source-map';
}
module.exports = config;