-
Notifications
You must be signed in to change notification settings - Fork 1
/
config-overrides.js
29 lines (24 loc) · 1.01 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
const JavaScriptObfuscator = require('webpack-obfuscator');
const webpack = require('webpack');
module.exports = function override(config, env) {
if (!config.plugins) {
config.plugins = [];
}
config.plugins.push(new webpack.DefinePlugin({ 'process.env.BUILD_EXPIRE': JSON.stringify(process.env.BUILD_EXPIRE) }));
const version = process.env.REACT_APP_GIT_SHA || 'snapshot';
const commonJSFilename = `commons.${version}.js`;
if (process.env.NODE_ENV === 'production') {
config.plugins.push(
new webpack.optimize.CommonsChunkPlugin({
name: 'commons',
filename: commonJSFilename,
minChunks: module => /node_modules/.test(module.resource)
})
);
const domain = process.env.BUILD_DOMAIN ? process.env.BUILD_DOMAIN.split(',') : [];
config.plugins.push(
new JavaScriptObfuscator({ rotateUnicodeArray: true, domainLock: domain }, [commonJSFilename])
);
}
return config;
};