-
Notifications
You must be signed in to change notification settings - Fork 94
/
webpack.config.babel.js
68 lines (62 loc) · 1.35 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
const {
createConfig,
// Feature blocks
addPlugins,
entryPoint,
env,
group,
performance,
setMode,
setOutput,
sourceMaps,
// Shorthand setters
babel,
css,
devServer,
extractText,
typescript,
postcss
} = require('webpack-blocks')
const HtmlWebpackPlugin = require('html-webpack-plugin')
const path = require('path')
const cssnano = require('cssnano')
const developmentConfig = () =>
group([
sourceMaps(),
devServer({
proxy: {
'/api/*': { target: 'http://localhost:4000' }
}
}),
performance({
// Increase performance budget thresholds for development mode
maxAssetSize: 1500000,
maxEntrypointSize: 1500000
}),
css.modules()
])
const productionConfig = () =>
group([
css.modules(),
postcss({
plugins: [cssnano()]
}),
extractText('css/[name].[contenthash:hex:8].css')
])
module.exports = createConfig([
setMode(process.env.NODE_ENV || 'development'),
babel(),
typescript({ configFileName: path.resolve(__dirname, './tsconfig.json') }),
addPlugins([
new HtmlWebpackPlugin({
inject: true,
template: './index.html'
})
]),
env('development', [entryPoint('./src/index.dev.js'), developmentConfig()]),
env('production', [
entryPoint('./src/index.js'),
setOutput('./build/bundle.js'),
productionConfig()
])
])