-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwebpack.config.babel.js
106 lines (103 loc) · 2.42 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
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
import webpack from 'webpack';
import path from 'path';
// Plugins
import ExtractTextPlugin from 'extract-text-webpack-plugin';
import StyleLintPlugin from 'stylelint-webpack-plugin';
import CopyWebpackPlugin from 'copy-webpack-plugin';
import ImageminPlugin from 'imagemin-webpack-plugin';
// Postcss
import lineheightconversion from 'postcss-line-height-px-to-unitless';
import cssnext from 'postcss-cssnext';
import cssnano from 'cssnano';
import lost from 'lost';
export default {
context: path.resolve(__dirname, './src/js'),
entry: {
app: './app'
},
output: {
filename: '[name].min.js',
path: path.resolve(__dirname, './build/js'),
publicPath: './build/js'
},
resolve: {
modules: [path.resolve(__dirname, './src'), 'node_modules']
},
module: {
rules: [{
test: /\.js$/,
exclude: /node_modules/,
loader: 'eslint-loader',
enforce: 'pre'
}, {
test: /\.js$/,
exclude: /node_modules/,
loader: 'babel-loader'
}, {
test: /\.scss$/,
exclude: /node_modules/,
use: ExtractTextPlugin.extract({
use: [{
loader: 'css-loader'
}, {
loader: 'postcss-loader',
options: {
plugins: () => [
lineheightconversion(),
lost(),
cssnext({
browsers: 'last 2 versions'
}),
cssnano({
autoprefixer: false,
mergeRules: false,
zindex: false
})
]
}
}, {
loader: 'sass-loader'
}],
fallback: 'style-loader'
})
}]
},
plugins: [
new webpack.DefinePlugin({
'process.env': { NODE_ENV: JSON.stringify('production') }
}),
new webpack.optimize.UglifyJsPlugin({
compress: {
warnings: false
}
}),
new ExtractTextPlugin({
filename: '../css/[name].min.css',
allChunks: true
}),
new StyleLintPlugin({
context: './src/scss',
syntax: 'scss'
}),
new CopyWebpackPlugin([{
from: '../media/',
to: '../media/'
}]),
new ImageminPlugin({
test: /\.(jpe?g|png|gif|svg)$/i,
pngquant: {
quality: '65-80'
},
jpegtran: {
progressive: true
},
svgo: {
removeViewBox: true
}
})
],
devtool: 'source-map',
devServer: {
contentBase: path.resolve(__dirname, './src')
}
};