-
Notifications
You must be signed in to change notification settings - Fork 0
/
kyt.webpack.config.js
executable file
·46 lines (41 loc) · 1.65 KB
/
kyt.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
const path = require('path')
const merge = require('webpack-merge')
// Base modified webpack config for use in development and stage kyt configs
module.exports = (baseConfig, options) => {
// Add src folder to resolve.
// This way we can do require('App') instead of require('src/App')
const config = merge(baseConfig, {
resolve: {
modules: [path.resolve(__dirname, 'src')],
alias: {
assets: path.join(__dirname, 'src/public')
}
},
// Callback to handle fs error on linux
node: {
fs: 'empty'
}
})
// Enable `cheap-eval-source-map` on development for a little bit faster builds.
// Unfortunately the source map generated aren't really good, so comment this lines
// if faster builds are not that important to you as source maps are.
if (options.environment === 'development') {
config.devtool = 'cheap-eval-source-map'
}
// Set webpack-hot-middleware noInfo to true to disable informational console logging
// and remove reload=true to disable auto-reload of the page when webpack gets stuck
if (options.type === 'client') {
let hotEntry = config.entry.main.find(entry => entry.match(/hot-middleware/g))
if (hotEntry) {
hotEntry = hotEntry.replace('reload', 'noInfo')
config.entry.main = config.entry.main.filter(entry => !entry.match(/hot-middleware/g))
config.entry.main.push(hotEntry)
}
}
// Add babel stage-2 preset
const babelLoader = baseConfig.module.rules.find(loader => loader.loader === 'babel-loader')
if (babelLoader && babelLoader.options && babelLoader.options.presets.length) {
babelLoader.options.presets.push('stage-2')
}
return config
}