From d2c269f037946b1bbfce2589c44544e310cf1921 Mon Sep 17 00:00:00 2001 From: Matthias Osswald Date: Tue, 29 Mar 2022 10:29:07 +0200 Subject: [PATCH] [INTERNAL] ApplicationBuilder: Align task order of "minify" In the LibraryBuilder the task is executed before the generateManifestBundle and before any of the bundle tasks. Therefore, the minify task should be executed right after the replaceVersion task. --- lib/types/application/ApplicationBuilder.js | 42 +++++++++---------- .../types/application/ApplicationBuilder.js | 10 ++--- 2 files changed, 26 insertions(+), 26 deletions(-) diff --git a/lib/types/application/ApplicationBuilder.js b/lib/types/application/ApplicationBuilder.js index d82d05a8b..debd7fb01 100644 --- a/lib/types/application/ApplicationBuilder.js +++ b/lib/types/application/ApplicationBuilder.js @@ -43,6 +43,27 @@ class ApplicationBuilder extends AbstractBuilder { }); }); + // Support rules should not be minified to have readable code in the Support Assistant + const minificationPattern = ["/**/*.js", "!**/*.support.js"]; + if (["2.6"].includes(project.specVersion)) { + const minificationExcludes = project.builder && project.builder.minification && + project.builder.minification.excludes; + if (minificationExcludes) { + // TODO 3.0: namespaces should become mandatory, see existing check above + const patternPrefix = project.metadata.namespace ? "/resources/" : "/"; + this.enhancePatternWithExcludes(minificationPattern, minificationExcludes, patternPrefix); + } + } + this.addTask("minify", async () => { + return getTask("minify").task({ + workspace: resourceCollections.workspace, + taskUtil, + options: { + pattern: minificationPattern + } + }); + }); + this.addTask("generateFlexChangesBundle", async () => { const generateFlexChangesBundle = getTask("generateFlexChangesBundle").task; return generateFlexChangesBundle({ @@ -67,27 +88,6 @@ class ApplicationBuilder extends AbstractBuilder { }); } - // Support rules should not be minified to have readable code in the Support Assistant - const minificationPattern = ["/**/*.js", "!**/*.support.js"]; - if (["2.6"].includes(project.specVersion)) { - const minificationExcludes = project.builder && project.builder.minification && - project.builder.minification.excludes; - if (minificationExcludes) { - // TODO 3.0: namespaces should become mandatory, see existing check above - const patternPrefix = project.metadata.namespace ? "/resources/" : "/"; - this.enhancePatternWithExcludes(minificationPattern, minificationExcludes, patternPrefix); - } - } - this.addTask("minify", async () => { - return getTask("minify").task({ - workspace: resourceCollections.workspace, - taskUtil, - options: { - pattern: minificationPattern - } - }); - }); - const componentPreload = project.builder && project.builder.componentPreload; if (componentPreload && (componentPreload.namespaces || componentPreload.paths)) { this.addTask("generateComponentPreload", async () => { diff --git a/test/lib/types/application/ApplicationBuilder.js b/test/lib/types/application/ApplicationBuilder.js index 4bf00ac38..0e6185d6b 100644 --- a/test/lib/types/application/ApplicationBuilder.js +++ b/test/lib/types/application/ApplicationBuilder.js @@ -60,9 +60,9 @@ test("Instantiation", (t) => { "escapeNonAsciiCharacters", "replaceCopyright", "replaceVersion", + "minify", "generateFlexChangesBundle", "generateManifestBundle", - "minify", "generateComponentPreload", "generateStandaloneAppBundle", "transformBootstrapHtml", @@ -83,9 +83,9 @@ test("Instantiation without component preload project configuration", (t) => { "escapeNonAsciiCharacters", "replaceCopyright", "replaceVersion", + "minify", "generateFlexChangesBundle", "generateManifestBundle", - "minify", "generateComponentPreload", "generateStandaloneAppBundle", "transformBootstrapHtml", @@ -107,8 +107,8 @@ test("Instantiation without project namespace", (t) => { "escapeNonAsciiCharacters", "replaceCopyright", "replaceVersion", - "generateFlexChangesBundle", "minify", + "generateFlexChangesBundle", "generateStandaloneAppBundle", "transformBootstrapHtml", "generateBundle", @@ -131,10 +131,10 @@ test("Instantiation with custom tasks", (t) => { "replaceCopyright", "minify--1", "replaceVersion", - "generateFlexChangesBundle", - "generateManifestBundle", "minify", "replaceVersion--1", + "generateFlexChangesBundle", + "generateManifestBundle", "generateComponentPreload", "generateStandaloneAppBundle", "transformBootstrapHtml",