-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathwebpack.config.babel.js
84 lines (76 loc) · 1.57 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
import webpack from 'webpack';
import path from 'path';
import ExtractTextPlugin from 'extract-text-webpack-plugin';
import StyleLintPlugin from 'stylelint-webpack-plugin';
const BUILD_DIR = path.resolve( __dirname, 'dist' );
const APP_DIR = path.resolve( __dirname, 'src' );
const nodeEnv = process.env.NODE_ENV || 'development';
const isProduction = 'production' === nodeEnv;
const config = {
cache: true,
entry: APP_DIR + '/index.js',
output: {
path: BUILD_DIR,
filename: 'js/main.js'
},
resolve: {
modules: ['node_modules'],
},
module: {
rules: [
{
test: /\.js$/,
enforce: 'pre',
loader: 'eslint-loader',
options: {
fix: true
}
},
{
test: /\.jsx?$/,
exclude: /node_modules/,
use: [{
loader: 'babel-loader',
}]
},
{
test: /\.css$/,
loaders: ExtractTextPlugin.extract( {
fallback: 'style-loader',
use: isProduction
? 'css-loader?minimize!postcss-loader'
: 'css-loader?sourceMap!postcss-loader?sourceMap'
} )
},
]
},
plugins: [
new webpack.NoEmitOnErrorsPlugin(),
new ExtractTextPlugin( {
filename: 'css/[name].css',
allChunks: true
} ),
new StyleLintPlugin( {
files: "src/**/*.css",
fix: true,
} ),
new webpack.DefinePlugin( {
'process.env': {
NODE_ENV: JSON.stringify( nodeEnv )
}
} ),
],
stats: { colors: true },
};
// uglify plugin
if ( isProduction ) {
config.plugins.push(
new webpack.optimize.UglifyJsPlugin( {
compress: { warnings: false },
output: { comments: false },
sourceMap: true
} )
);
config.plugins.push();
}
module.exports = config;