diff --git a/.changeset/smooth-roses-laugh.md b/.changeset/smooth-roses-laugh.md
new file mode 100644
index 00000000000..9d66d500b92
--- /dev/null
+++ b/.changeset/smooth-roses-laugh.md
@@ -0,0 +1,5 @@
+---
+"app-builder-lib": patch
+---
+
+add disableDefaultIgnoredFiles option
diff --git a/docs/generated/PlatformSpecificBuildOptions.md b/docs/generated/PlatformSpecificBuildOptions.md
index 8de4f17aac1..5fc003aacea 100644
--- a/docs/generated/PlatformSpecificBuildOptions.md
+++ b/docs/generated/PlatformSpecificBuildOptions.md
@@ -12,6 +12,9 @@
compression
= normal
“store” | “normal” | “maximum” | “undefined” - The compression level. If you want to rapidly test build, store
can reduce build time significantly. maximum
doesn’t lead to noticeable size difference, but increase build time.
+disableDefaultIgnoredFiles
= false
Boolean | “undefined” - Whether to exclude all default ignored files(https://www.electron.build/configuration/contents#files) and options. Defaults to false
.
+
+
files
The files configuration.
diff --git a/packages/app-builder-lib/scheme.json b/packages/app-builder-lib/scheme.json
index f1cfdce4ae9..096d6ae0193 100644
--- a/packages/app-builder-lib/scheme.json
+++ b/packages/app-builder-lib/scheme.json
@@ -1652,6 +1652,14 @@
"description": "Whether to infer update channel from application version pre-release components. e.g. if version `0.12.1-alpha.1`, channel will be set to `alpha`. Otherwise to `latest`.",
"type": "boolean"
},
+ "disableDefaultIgnoredFiles": {
+ "default": false,
+ "description": "Whether to exclude all default ignored files(https://www.electron.build/configuration/contents#files) and options. Defaults to `false`.",
+ "type": [
+ "null",
+ "boolean"
+ ]
+ },
"electronLanguages": {
"anyOf": [
{
@@ -2275,6 +2283,14 @@
"description": "Whether to infer update channel from application version pre-release components. e.g. if version `0.12.1-alpha.1`, channel will be set to `alpha`. Otherwise to `latest`.",
"type": "boolean"
},
+ "disableDefaultIgnoredFiles": {
+ "default": false,
+ "description": "Whether to exclude all default ignored files(https://www.electron.build/configuration/contents#files) and options. Defaults to `false`.",
+ "type": [
+ "null",
+ "boolean"
+ ]
+ },
"electronLanguages": {
"anyOf": [
{
@@ -2905,6 +2921,14 @@
"description": "Whether to infer update channel from application version pre-release components. e.g. if version `0.12.1-alpha.1`, channel will be set to `alpha`. Otherwise to `latest`.",
"type": "boolean"
},
+ "disableDefaultIgnoredFiles": {
+ "default": false,
+ "description": "Whether to exclude all default ignored files(https://www.electron.build/configuration/contents#files) and options. Defaults to `false`.",
+ "type": [
+ "null",
+ "boolean"
+ ]
+ },
"electronLanguages": {
"anyOf": [
{
@@ -6057,6 +6081,14 @@
"description": "Whether to infer update channel from application version pre-release components. e.g. if version `0.12.1-alpha.1`, channel will be set to `alpha`. Otherwise to `latest`.",
"type": "boolean"
},
+ "disableDefaultIgnoredFiles": {
+ "default": false,
+ "description": "Whether to exclude all default ignored files(https://www.electron.build/configuration/contents#files) and options. Defaults to `false`.",
+ "type": [
+ "null",
+ "boolean"
+ ]
+ },
"electronLanguages": {
"anyOf": [
{
@@ -6695,6 +6727,14 @@
}
]
},
+ "disableDefaultIgnoredFiles": {
+ "default": false,
+ "description": "Whether to exclude all default ignored files(https://www.electron.build/configuration/contents#files) and options. Defaults to `false`.",
+ "type": [
+ "null",
+ "boolean"
+ ]
+ },
"disableSanityCheckAsar": {
"default": false,
"description": "Whether to disable sanity check asar package (useful for custom electron forks that implement their own encrypted integrity validation)",
diff --git a/packages/app-builder-lib/src/options/PlatformSpecificBuildOptions.ts b/packages/app-builder-lib/src/options/PlatformSpecificBuildOptions.ts
index d1101975164..1f23932a8c2 100644
--- a/packages/app-builder-lib/src/options/PlatformSpecificBuildOptions.ts
+++ b/packages/app-builder-lib/src/options/PlatformSpecificBuildOptions.ts
@@ -50,6 +50,13 @@ export interface PlatformSpecificBuildOptions extends TargetSpecificOptions {
*/
readonly compression?: CompressionLevel | null
+ /**
+ * Whether to exclude all default ignored files(https://www.electron.build/configuration/contents#files) and options. Defaults to `false`.
+ *
+ * @default false
+ */
+ disableDefaultIgnoredFiles?: boolean | null
+
files?: Array | FileSet | string | null
extraResources?: Array | FileSet | string | null
extraFiles?: Array | FileSet | string | null
diff --git a/packages/app-builder-lib/src/util/NodeModuleCopyHelper.ts b/packages/app-builder-lib/src/util/NodeModuleCopyHelper.ts
index c26fa25b8f1..ca785588123 100644
--- a/packages/app-builder-lib/src/util/NodeModuleCopyHelper.ts
+++ b/packages/app-builder-lib/src/util/NodeModuleCopyHelper.ts
@@ -1,6 +1,6 @@
import BluebirdPromise from "bluebird-lst"
import { CONCURRENCY } from "builder-util"
-import { lstat, readdir } from "fs-extra"
+import { lstat, readdir, lstatSync } from "fs-extra"
import * as path from "path"
import { excludedNames, FileMatcher } from "../fileMatcher"
import { Packager } from "../packager"
@@ -76,7 +76,9 @@ export class NodeModuleCopyHelper extends FileCopyHelper {
return null
}
- if (!forceIncluded) {
+ // check if filematcher matches the files array as more important than the default excluded files.
+ const fileMatched = filter != null && filter(dirPath, lstatSync(dirPath))
+ if (!fileMatched || !forceIncluded || !!this.packager.config.disableDefaultIgnoredFiles) {
for (const ext of nodeModuleExcludedExts) {
if (name.endsWith(ext)) {
return null