-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwebpack-config.js
102 lines (100 loc) · 2.17 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
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
const path = require('path')
const autoprefixer = require('autoprefixer')
const postcssImport = require('postcss-import')
const postcssImportUrl = require('postcss-import-url')
const postcssCustomProperties = require('postcss-custom-properties')
const CleanPlugin = require('clean-webpack-plugin')
const CopyPlugin = require('copy-webpack-plugin')
const ImageminPlugin = require('imagemin-webpack-plugin').default
const imageminMozjpeg = require('imagemin-mozjpeg')
module.exports = {
dev: 'cheap-module-source-map',
context: path.join(__dirname, './src'),
entry: {
js: ['babel-polyfill', './index.js'],
html: './index.html'
},
output: {
path: path.join(__dirname, './docs'),
filename: 'bundle.js'
},
module: {
loaders: [
{
test: /\.html$/,
loader: 'file?name=[name].[ext]'
},
{
test: /\.js$/,
exclude: /node_modules/,
loaders: [
'react-hot',
'babel-loader'
]
},
{
test: /\.png$/,
loader: 'url-loader?limit=100000'
},
{
test: /\.jpg$/,
loader: 'url-loader?limit=100000'
},
{
test: /\.json$/,
loader: 'json'
},
{
test: /\.css$/,
loaders: [
'style-loader',
'css-loader?modules&minimize&importLoaders=1&localIdentName=[hash:base64:5]',
'postcss-loader'
]
}
]
},
plugins: [
new CleanPlugin(['docs'], {
verbose: true,
dry: process.env.NODE_ENV !== 'production'
}),
new CopyPlugin([
{
from: 'CNAME'
},
{
from: 'service-worker.js'
},
{
from: 'media/**'
},
{
context: '../node_modules',
from: 'font-awesome/**',
to: './vendors/'
}
]),
new ImageminPlugin({
test: 'media/*',
pngquant: {
quality: '80-90'
},
jpegtran: null,
plugins: [
imageminMozjpeg({
quality: '80, 90'
})
]
})
],
resolve: {
extensions: ['', '.js', '.css']
},
postcss: [
autoprefixer,
postcssImport,
postcssImportUrl,
postcssCustomProperties
]
}