Skip to content

Commit 20c12be

Browse files
committed
feat(): search for react-script in package dependencies as well as devDependencies
Close #2532
1 parent 67305af commit 20c12be

File tree

2 files changed

+11
-11
lines changed

2 files changed

+11
-11
lines changed

packages/electron-builder-lib/src/configuration.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,7 @@ export interface Configuration extends PlatformSpecificBuildOptions {
142142
/**
143143
* The name of a built-in configuration preset or path to config file (relative to project dir). Currently, only `react-cra` is supported.
144144
*
145-
* If `react-scripts` in the app dev dependencies, `react-cra` will be set automatically. Set to `null` to disable automatic detection.
145+
* If `react-scripts` in the app dependencies, `react-cra` will be set automatically. Set to `null` to disable automatic detection.
146146
*/
147147
extends?: string | null
148148

packages/electron-builder-lib/src/util/config.ts

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -46,16 +46,16 @@ export async function getConfig(projectDir: string, configPath: string | null, c
4646

4747
let extendsSpec = config.extends
4848
if (extendsSpec == null && extendsSpec !== null) {
49-
const devDependencies = (await packageMetadata.value || {}).devDependencies
50-
if (devDependencies != null) {
51-
if ("react-scripts" in devDependencies) {
52-
extendsSpec = "react-cra"
53-
config.extends = extendsSpec
54-
}
55-
else if ("electron-webpack" in devDependencies) {
56-
extendsSpec = "electron-webpack/electron-builder.yml"
57-
config.extends = extendsSpec
58-
}
49+
const metadata = await packageMetadata.value || {}
50+
const devDependencies = metadata.devDependencies
51+
const dependencies = metadata.dependencies
52+
if ((dependencies != null && "react-scripts" in dependencies) || (devDependencies != null && "react-scripts" in devDependencies)) {
53+
extendsSpec = "react-cra"
54+
config.extends = extendsSpec
55+
}
56+
else if (devDependencies != null && "electron-webpack" in devDependencies) {
57+
extendsSpec = "electron-webpack/electron-builder.yml"
58+
config.extends = extendsSpec
5959
}
6060
}
6161

0 commit comments

Comments
 (0)