|
1 | 1 | process.env.NODE_ENV = process.env.NODE_ENV || 'development'; |
2 | 2 |
|
3 | | -const semver = require('semver'); |
4 | | - |
5 | 3 | const { scriptVersion } = require('./utils/paths'); |
6 | | -const overrides = require('../config-overrides'); |
7 | | -const scriptPkg = require(`${scriptVersion}/package.json`); |
8 | | - |
9 | | -const pathsConfigPath = `${scriptVersion}/config/paths.js`; |
10 | | -const pathsConfig = require(pathsConfigPath); |
11 | 4 |
|
12 | 5 | // override paths in memory |
13 | | -require.cache[require.resolve(pathsConfigPath)].exports = |
14 | | - overrides.paths(pathsConfig, process.env.NODE_ENV); |
15 | | - |
16 | | -// CRA 2.1.2 switched to using a webpack config factory |
17 | | -// https://github.com/facebook/create-react-app/pull/5722 |
18 | | -// https://github.com/facebook/create-react-app/releases/tag/v2.1.2 |
19 | | -const isWebpackFactory = semver.gte(scriptPkg && scriptPkg.version, '2.1.2'); |
20 | | - |
21 | | -const webpackConfigPath = `${scriptVersion}/config/webpack.config${!isWebpackFactory ? '.dev' : ''}`; |
22 | | -const devServerConfigPath = `${scriptVersion}/config/webpackDevServer.config.js`; |
23 | | -const webpackConfig = require(webpackConfigPath); |
24 | | -const devServerConfig = require(devServerConfigPath); |
| 6 | +require('../overrides/paths'); |
25 | 7 |
|
26 | 8 | // override config in memory |
27 | | -require.cache[require.resolve(webpackConfigPath)].exports = isWebpackFactory |
28 | | - ? (env) => overrides.webpack(webpackConfig(env), env) |
29 | | - : overrides.webpack(webpackConfig, process.env.NODE_ENV); |
30 | | - |
31 | | -require.cache[require.resolve(devServerConfigPath)].exports = |
32 | | - overrides.devServer(devServerConfig, process.env.NODE_ENV); |
| 9 | +require('../overrides/webpack'); |
| 10 | +require('../overrides/devServer'); |
33 | 11 |
|
34 | 12 | // run original script |
35 | 13 | require(`${scriptVersion}/scripts/start`); |
0 commit comments