Skip to content

Commit 6591eea

Browse files
committed
Issue 45
1 parent 59e4367 commit 6591eea

File tree

2 files changed

+25
-6
lines changed

2 files changed

+25
-6
lines changed

packages/react-scripts/config/paths-wptheme.js

Lines changed: 23 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,12 @@
1010

1111
const path = require('path');
1212
const fs = require('fs');
13-
const getPublicUrlOrPath = require('@devloco/create-react-wptheme-utils/getPublicUrlOrPath');
13+
const getPublicUrlOrPath = require('react-dev-utils/getPublicUrlOrPath');
1414

1515
// Make sure any symlinks in the project folder are resolved:
1616
// https://github.com/facebook/create-react-app/issues/637
1717
const appDirectory = fs.realpathSync(process.cwd());
18-
const resolveApp = relativePath => path.resolve(appDirectory, relativePath);
18+
const resolveApp = (relativePath) => path.resolve(appDirectory, relativePath);
1919

2020
// We use `PUBLIC_URL` environment variable or "homepage" field to infer
2121
// "public path" at which the app is served.
@@ -45,7 +45,7 @@ const moduleFileExtensions = [
4545

4646
// Resolve file paths in the same order as webpack
4747
const resolveModule = (resolveFn, filePath) => {
48-
const extension = moduleFileExtensions.find(extension =>
48+
const extension = moduleFileExtensions.find((extension) =>
4949
fs.existsSync(resolveFn(`${filePath}.${extension}`))
5050
);
5151

@@ -76,7 +76,8 @@ module.exports = {
7676
};
7777

7878
// @remove-on-eject-begin
79-
const resolveOwn = relativePath => path.resolve(__dirname, '..', relativePath);
79+
const resolveOwn = (relativePath) =>
80+
path.resolve(__dirname, '..', relativePath);
8081

8182
// config before eject: we're in ./node_modules/react-scripts/config/
8283
module.exports = {
@@ -140,3 +141,21 @@ if (
140141
// @remove-on-eject-end
141142

142143
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+
);

packages/react-scripts/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@devloco/react-scripts-wptheme",
3-
"version": "3.4.0-wp.1",
3+
"version": "3.4.0-wp.2",
44
"description": "Configuration and scripts for Create React WP Theme.",
55
"repository": {
66
"type": "git",
@@ -94,7 +94,7 @@
9494
"webpack-dev-server": "3.10.2",
9595
"webpack-manifest-plugin": "2.2.0",
9696
"workbox-webpack-plugin": "4.3.1",
97-
"@devloco/create-react-wptheme-utils": "^3.4.0-wp.1"
97+
"@devloco/create-react-wptheme-utils": "^3.4.0-wp.2"
9898
},
9999
"devDependencies": {
100100
"react": "^16.12.0",

0 commit comments

Comments
 (0)