Skip to content

Commit a79b35a

Browse files
committed
Issue45
1 parent 6591eea commit a79b35a

File tree

3 files changed

+20
-20
lines changed

3 files changed

+20
-20
lines changed

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

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -143,19 +143,18 @@ if (
143143
module.exports.moduleFileExtensions = moduleFileExtensions;
144144

145145
// 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-
);
146+
const getUserConfig = require('@devloco/create-react-wptheme-utils/getUserConfig');
147+
const wpThemeUserConfig = getUserConfig(module.exports, process.env.NODE_ENV);
148+
149+
// wptheme Issue 45; only the PROD wpThemeUserConfig object has a "homepage" member, so this works...
150+
const wpThemeConfigHomepage =
151+
(wpThemeUserConfig && wpThemeUserConfig.homepage) ||
152+
require(resolveApp('package.json')).homepage; // ... else use the one from the package.json file.
151153

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"
154+
const wpThemePathsHomepage = process.env.PUBLIC_URL || wpThemeConfigHomepage; // default to the create-react-app setting
156155

157156
module.exports.publicUrlOrPath = getPublicUrlOrPath(
158157
/*isEnvDevelopment*/ false, // wptheme always uses PROD paths.
159-
wpThemeHomepage,
158+
wpThemePathsHomepage,
160159
process.env.PUBLIC_URL
161160
);

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

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ const sassModuleRegex = /\.module\.(scss|sass)$/;
7373

7474
// This is the production and development configuration.
7575
// It is focused on developer experience, fast rebuilds, and a minimal bundle.
76-
module.exports = function(webpackEnv) {
76+
module.exports = function (webpackEnv) {
7777
const isEnvDevelopment = webpackEnv === 'development';
7878
const isEnvProduction = webpackEnv === 'production';
7979

@@ -196,12 +196,13 @@ module.exports = function(webpackEnv) {
196196
publicPath: paths.publicUrlOrPath,
197197
// Point sourcemap entries to original disk location (format as URL on Windows)
198198
devtoolModuleFilenameTemplate: isEnvProduction
199-
? info =>
199+
? (info) =>
200200
path
201201
.relative(paths.appSrc, info.absoluteResourcePath)
202202
.replace(/\\/g, '/')
203203
: isEnvDevelopment &&
204-
(info => path.resolve(info.absoluteResourcePath).replace(/\\/g, '/')),
204+
((info) =>
205+
path.resolve(info.absoluteResourcePath).replace(/\\/g, '/')),
205206
// Prevents conflicts when multiple webpack runtimes (from different apps)
206207
// are used on the same page.
207208
jsonpFunction: `webpackJsonp${appPackageJson.name}`,
@@ -284,7 +285,7 @@ module.exports = function(webpackEnv) {
284285
// https://twitter.com/wSokra/status/969679223278505985
285286
// https://github.com/facebook/create-react-app/issues/5358
286287
runtimeChunk: {
287-
name: entrypoint => `runtime-${entrypoint.name}`,
288+
name: (entrypoint) => `runtime-${entrypoint.name}`,
288289
},
289290
},
290291
resolve: {
@@ -302,8 +303,8 @@ module.exports = function(webpackEnv) {
302303
// `web` extension prefixes have been added for better support
303304
// for React Native Web.
304305
extensions: paths.moduleFileExtensions
305-
.map(ext => `.${ext}`)
306-
.filter(ext => useTypeScript || !ext.includes('ts')),
306+
.map((ext) => `.${ext}`)
307+
.filter((ext) => useTypeScript || !ext.includes('ts')),
307308
alias: {
308309
// Support React Native Web
309310
// https://www.smashingmagazine.com/2016/08/a-glimpse-into-the-future-with-react-native-for-web/
@@ -643,7 +644,7 @@ module.exports = function(webpackEnv) {
643644
// wptheme added FileWatcherPlugin
644645
// For create-react-wptheme: watch addition files in the public folder for changes
645646
// touchFile is used to force WebPack to do a rebuild. It must be a file that WebPack is watching.
646-
new FileWatcherPlugin(fileWatcherPluginConfig),
647+
isEnvDevelopment && new FileWatcherPlugin(fileWatcherPluginConfig),
647648
// If you require a missing module and then `npm install` it, you still have
648649
// to restart the development server for webpack to discover it. This plugin
649650
// makes the discovery automatic so you don't have to restart.
@@ -674,7 +675,7 @@ module.exports = function(webpackEnv) {
674675
return manifest;
675676
}, seed);
676677
const entrypointFiles = entrypoints.main.filter(
677-
fileName => !fileName.endsWith('.map')
678+
(fileName) => !fileName.endsWith('.map')
678679
);
679680

680681
return {

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.2",
3+
"version": "3.4.0-wp.9",
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.2"
97+
"@devloco/create-react-wptheme-utils": "^3.4.0-wp.11"
9898
},
9999
"devDependencies": {
100100
"react": "^16.12.0",

0 commit comments

Comments
 (0)