2017-05-23 16:27:04 +03:00
|
|
|
const fs = require('fs');
|
|
|
|
const path = require('path');
|
|
|
|
|
|
|
|
// TODO: this will need to happen for prod and test too
|
2017-05-18 21:21:33 +03:00
|
|
|
const configPath = path.join(
|
|
|
|
__dirname,
|
|
|
|
'../node_modules/react-scripts/config/webpack.config.dev.js'
|
|
|
|
);
|
|
|
|
const orignalConfigPath = path.join(
|
|
|
|
__dirname,
|
|
|
|
'../node_modules/react-scripts/config/webpack.config.dev.original.js'
|
|
|
|
);
|
2017-05-23 16:27:04 +03:00
|
|
|
const enhancedConfigPath = path.join(__dirname, './webpack.config.dev.js');
|
|
|
|
|
|
|
|
// bit of healthy callback hell for making it spicy
|
|
|
|
fs.readFile(configPath, (error, orignalConfig) => {
|
2017-05-18 21:21:33 +03:00
|
|
|
if (error) {
|
2017-05-23 16:27:04 +03:00
|
|
|
console.log('Original config read error', error);
|
2017-05-18 21:21:33 +03:00
|
|
|
} else {
|
|
|
|
fs.writeFile(orignalConfigPath, orignalConfig, error => {
|
|
|
|
if (error) {
|
2017-05-23 16:27:04 +03:00
|
|
|
console.log('Original config write error', error);
|
2017-05-18 21:21:33 +03:00
|
|
|
} else {
|
2017-05-23 16:27:04 +03:00
|
|
|
fs.readFile(enhancedConfigPath, (error, enhancedConfig) => {
|
2017-05-18 21:21:33 +03:00
|
|
|
if (error) {
|
2017-05-23 16:27:04 +03:00
|
|
|
console.log('Enhanced config read error', error);
|
2017-05-18 21:21:33 +03:00
|
|
|
} else {
|
|
|
|
fs.writeFile(configPath, enhancedConfig, error => {
|
|
|
|
if (error) {
|
2017-05-23 16:27:04 +03:00
|
|
|
console.log('Enhanced config write error', error);
|
|
|
|
}
|
2017-05-18 21:21:33 +03:00
|
|
|
});
|
2017-05-23 16:27:04 +03:00
|
|
|
}
|
2017-05-18 21:21:33 +03:00
|
|
|
});
|
2017-05-23 16:27:04 +03:00
|
|
|
}
|
2017-05-18 21:21:33 +03:00
|
|
|
});
|
2017-05-23 16:27:04 +03:00
|
|
|
}
|
2017-05-18 21:21:33 +03:00
|
|
|
});
|
|
|
|
|