-
Notifications
You must be signed in to change notification settings - Fork 1
/
config-overrides.js
69 lines (67 loc) · 2.08 KB
/
config-overrides.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
const path = require('path')
const HtmlWebpackPlugin = require('html-webpack-plugin')
const BundleAnalyzerPlugin = require('webpack-bundle-analyzer').BundleAnalyzerPlugin
module.exports = function override (config, env) {
// remove the css loader to simplify things
config.module.rules[2].oneOf = config.module.rules[2].oneOf.filter(function (l) {
const test = l.test && l.test.toString()
return test !== /\.css$/
})
config.optimization.runtimeChunk = false;
config.optimization.splitChunks = {
cacheGroups: {
default: false
}
};
// compile sass, this comes first and compresses css as well as loading sass/scss
// https://github.com/facebookincubator/create-react-app/issues/2498
config.module.rules[2].oneOf.splice(0, 0,
{
test: /\.(sass|scss|css)$/,
use: [
'style-loader',
'css-loader',
{
loader: 'sass-loader',
options: {
sassOptions: {
outputStyle: 'compressed',
includePaths: [path.resolve(__dirname, 'node_modules')],
}
}
}
]
},
)
if (env === 'production') {
// set the output filename to just socket.js
config.output.filename = 'static/socket.js'
config.output.chunkFilename = 'static/socket.[chunkhash:8].chunk.js'
// if run with `ANALYSE=1 yarn build` create report.js size report
if (process.env.ANALYSE) {
config.plugins.push(
new BundleAnalyzerPlugin({
analyzerMode: 'static',
reportFilename: 'report.html',
})
)
}
}
// add another output file at /simple/ and /appointments/
config.plugins.splice(2, 0,
new HtmlWebpackPlugin({
inject: true,
template: path.resolve(__dirname, 'public', 'simple/index.html'),
filename: 'simple/index.html'
})
)
config.plugins.splice(2, 0,
new HtmlWebpackPlugin({
inject: true,
template: path.resolve(__dirname, 'public', 'appointments/index.html'),
filename: 'appointments/index.html'
})
)
// console.dir(config, { depth: 10, colors: true })
return config
}