-
Notifications
You must be signed in to change notification settings - Fork 1
/
webpack.config.js
78 lines (75 loc) · 1.9 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
'use strict';
const path = require('path');
const NODE_ENV = process.env.NODE_ENV || 'development';
const webpack = require('webpack');
const ExtractTextPlugin = require('extract-text-webpack-plugin');
const autoprefixer = require('autoprefixer');
const HtmlWebpackPlugin = require('html-webpack-plugin');
module.exports = {
entry: path.join(__dirname, '/src/index.js'),
output: {
path: path.join(__dirname, 'target'),
filename: 'bundle.js'
},
devtool: NODE_ENV === 'development' ? 'cheap-inline-module-source-map' : null,
watch: NODE_ENV === 'development',
watchOptions: {
poll: true,
},
resolve: {
extensions: ['', '.js', '.jsx', '.scss'],
fallback: path.join(__dirname, 'node_modules'),
},
resolveLoader: {
root: path.join(__dirname, 'node_modules'),
},
module: {
loaders: [
{
test: /\.scss$/,
loader: ExtractTextPlugin.extract('style-loader',
'css?minimize!postcss!sass'),
},
{
test: /\.jsx?$/,
loaders: ['babel-loader', 'eslint-loader'],
exclude: /node_modules/,
},
{
test: /\.svg$/,
loader: 'url-loader',
},
{
test: /\.png$/,
loader: 'file-loader',
},
]
},
postcss: [ autoprefixer({ browsers: ['last 2 versions'], }) ],
plugins: [
new webpack.NoErrorsPlugin(),
new ExtractTextPlugin('./bundle.css'),
new webpack.DefinePlugin({
NODE_ENV: JSON.stringify(NODE_ENV),
}),
new HtmlWebpackPlugin({
env: NODE_ENV,
template: __dirname + '/src/views/layout.html',
}),
],
};
if (NODE_ENV === 'production') {
module.exports.plugins.push(
new webpack.optimize.UglifyJsPlugin({
compress: {
warnings: false,
/* eslint camelcase: ["error", {properties: "never"}] */
drop_console: true,
unsafe: true,
},
output: {
comments: false,
},
})
);
}