|
10 | 10 |
|
11 | 11 | const path = require('path');
|
12 | 12 | const fs = require('fs');
|
13 |
| -const getPublicUrlOrPath = require('@devloco/create-react-wptheme-utils/getPublicUrlOrPath'); |
| 13 | +const getPublicUrlOrPath = require('react-dev-utils/getPublicUrlOrPath'); |
14 | 14 |
|
15 | 15 | // Make sure any symlinks in the project folder are resolved:
|
16 | 16 | // https://github.com/facebook/create-react-app/issues/637
|
17 | 17 | const appDirectory = fs.realpathSync(process.cwd());
|
18 |
| -const resolveApp = relativePath => path.resolve(appDirectory, relativePath); |
| 18 | +const resolveApp = (relativePath) => path.resolve(appDirectory, relativePath); |
19 | 19 |
|
20 | 20 | // We use `PUBLIC_URL` environment variable or "homepage" field to infer
|
21 | 21 | // "public path" at which the app is served.
|
@@ -45,7 +45,7 @@ const moduleFileExtensions = [
|
45 | 45 |
|
46 | 46 | // Resolve file paths in the same order as webpack
|
47 | 47 | const resolveModule = (resolveFn, filePath) => {
|
48 |
| - const extension = moduleFileExtensions.find(extension => |
| 48 | + const extension = moduleFileExtensions.find((extension) => |
49 | 49 | fs.existsSync(resolveFn(`${filePath}.${extension}`))
|
50 | 50 | );
|
51 | 51 |
|
@@ -76,7 +76,8 @@ module.exports = {
|
76 | 76 | };
|
77 | 77 |
|
78 | 78 | // @remove-on-eject-begin
|
79 |
| -const resolveOwn = relativePath => path.resolve(__dirname, '..', relativePath); |
| 79 | +const resolveOwn = (relativePath) => |
| 80 | + path.resolve(__dirname, '..', relativePath); |
80 | 81 |
|
81 | 82 | // config before eject: we're in ./node_modules/react-scripts/config/
|
82 | 83 | module.exports = {
|
@@ -140,3 +141,21 @@ if (
|
140 | 141 | // @remove-on-eject-end
|
141 | 142 |
|
142 | 143 | module.exports.moduleFileExtensions = moduleFileExtensions;
|
| 144 | + |
| 145 | +// wptheme Issue 45 |
| 146 | +const getWPThemeUserConfig = require('@devloco/create-react-wptheme-utils/getUserConfig'); |
| 147 | +const wpThemeUserConfig = getWPThemeUserConfig( |
| 148 | + module.exports, |
| 149 | + process.env.NODE_ENV |
| 150 | +); |
| 151 | + |
| 152 | +const wpThemeHomepage = |
| 153 | + process.env.PUBLIC_URL || // default to the create-react-app setting |
| 154 | + wpThemeUserConfig.homepage || // For wptheme... only the PROD wpThemeUserConfig object has a "homepage" member, so this works... |
| 155 | + require(resolveApp('package.json')).homepage; // For wptheme... dev builds use this as the "homepage" |
| 156 | + |
| 157 | +module.exports.publicUrlOrPath = getPublicUrlOrPath( |
| 158 | + /*isEnvDevelopment*/ false, // wptheme always uses PROD paths. |
| 159 | + wpThemeHomepage, |
| 160 | + process.env.PUBLIC_URL |
| 161 | +); |
0 commit comments