-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwebpack.config.babel.js
134 lines (131 loc) · 3.17 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
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
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';
import HtmlWebpackPlugin from 'html-webpack-plugin';
import BrowserSyncPlugin from 'browser-sync-webpack-plugin';
import CompressionPlugin from 'compression-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'),
entry: {
app: './js/app'
},
output: {
filename: 'js/[name].min.js',
path: path.resolve(__dirname, './build'),
publicPath: './'
},
resolve: {
symlinks: false,
modules: [path.resolve(__dirname, './src'), 'node_modules']
},
module: {
rules: [{
test: /\.js$/,
exclude: /node_modules/,
loader: 'eslint-loader',
enforce: 'pre'
}, {
test: /\.js$/,
exclude: /node_modules\/(?!addme)/,
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.HotModuleReplacementPlugin(),
new webpack.DefinePlugin({
'process.env.NODE_ENV': '"production"'
}),
new webpack.optimize.UglifyJsPlugin({
mangle: true,
compress: {
warnings: false,
screw_ie8: true
},
output: {
comments: false
},
}),
new ExtractTextPlugin({
filename: 'css/[name].min.css',
allChunks: true
}),
new StyleLintPlugin({
context: './src/scss',
syntax: 'scss'
}),
new CopyWebpackPlugin([{
from: './media/',
to: './media/'
}], { ignore: ['.DS_Store'] }),
new ImageminPlugin({
test: /\.(jpe?g|png|gif|svg)$/i,
pngquant: {
quality: '60-80'
},
jpegtran: {
progressive: true
},
svgo: {
removeViewBox: true
}
}),
new HtmlWebpackPlugin({
title: 'Home',
filename: './index.html',
template: './html/index.html',
minifiy: {
collapseWhitespace: true
},
cache: true,
inject: 'body'
}),
new CompressionPlugin({
asset: '[path].gz[query]',
algorithm: 'gzip',
test: /\.(js|css|html)$/,
threshold: 10240,
minRatio: 0.8
}),
new BrowserSyncPlugin({
host: 'localhost',
port: 3000,
server: { baseDir: ['build'] }
})
]
};