Skip to content

Commit

Permalink
[FIX] Minification excludes for application projects
Browse files Browse the repository at this point in the history
  • Loading branch information
larskissel committed Oct 19, 2021
1 parent 438b210 commit 7f6fd68
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 4 deletions.
4 changes: 3 additions & 1 deletion lib/types/application/ApplicationBuilder.js
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,9 @@ class ApplicationBuilder extends AbstractBuilder {
const minificationExcludes = project.builder && project.builder.minification &&
project.builder.minification.excludes;
if (minificationExcludes) {
this.enhancePatternWithExcludes(minificationPattern, 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("createDebugFiles", async () => {
Expand Down
33 changes: 30 additions & 3 deletions test/lib/builder/builder.js
Original file line number Diff line number Diff line change
Expand Up @@ -589,7 +589,7 @@ test.serial("Build application.k (package sub-components / componentPreload excl
});
});

test.serial("Build application.l", (t) => {
test.serial("Build application.l: minification excludes, w/ namespace", (t) => {
const destPath = "./test/tmp/build/application.l/dest";
const expectedPath = path.join("test", "expected", "build", "application.l", "dest");

Expand All @@ -609,6 +609,26 @@ test.serial("Build application.l", (t) => {
});
});

test.serial("Build application.l: minification excludes, w/o namespace", (t) => {
const destPath = "./test/tmp/build/application.l/dest";
const expectedPath = path.join("test", "expected", "build", "application.l", "dest");

return builder.build({
tree: applicationLTreeNoNamespace,
destPath,
excludedTasks: ["generateComponentPreload", "generateStandaloneAppBundle", "generateVersionInfo"]
}).then(() => {
return findFiles(expectedPath);
}).then((expectedFiles) => {
// Check for all directories and files
assert.directoryDeepEqual(destPath, expectedPath);
// Check for all file contents
return checkFileContentsIgnoreLineFeeds(t, expectedFiles, expectedPath, destPath);
}).then(() => {
t.pass();
});
});

test.serial("Build application.ø", (t) => {
const destPath = "./test/tmp/build/application.ø/dest";
const expectedPath = path.join("test", "expected", "build", "application.ø", "dest");
Expand Down Expand Up @@ -1411,13 +1431,20 @@ const applicationLTree = {
"builder": {
"minification": {
"excludes": [
"**/thirdparty/**",
"!**/subdir/thirdparty/File1.js"
"application/l/**/thirdparty/**",
"!application/l/subdir/thirdparty/File1.js"
]
}
}
};

const applicationLTreeNoNamespace = clone(applicationLTree);
applicationLTreeNoNamespace.metadata = {"name": "application.l"};
applicationLTreeNoNamespace.builder.minification.excludes = [
"**/thirdparty/**",
"!subdir/thirdparty/File1.js"
];

const applicationØTree = {
"id": "application.ø",
"version": "1.0.0",
Expand Down

0 comments on commit 7f6fd68

Please sign in to comment.