-
Notifications
You must be signed in to change notification settings - Fork 23
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[FEATURE] Support build minification excludes #653
Conversation
Supports the build configuration "minification excludes" introduced in specVersion 2.6. This allows to exclude JavaScript resources from minification (tasks: uglify and createDebugFiles). JIRA: CPOUI5FOUNDATION-405
Integration tests will be uploaded with the next commit. |
const minificationPattern = ["/**/*.js"]; | ||
if (["2.6"].includes(project.specVersion)) { | ||
const minification = (project.builder && project.builder.minification) || {}; | ||
this.enhancePatternWithExcludes(minificationPattern, minification.excludes); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should the pattern be prefixed with /resources/
here?
The default pattern for applications is /**/*.js
, so I'd expect the excludes to be possible for all paths, not just within /resources/
.
Or do I missing something here? For libraries it totally makese sense as we only process /resources/
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think you're right! I was always only thinking of libraries...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
But in that case we should still prepend /
, right?
So that patterns are something like sap/ui/demo/todo/thirdparty/**
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In the new implementation the Application-/LibraryBuilder has to set the prefix. Does it look like you expected it?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm... after thinking again about this, I'm not sure whether /
is really correct.
At least not in all cases.
The files within webapp
are available at the app namespace. e.g. /resources/sap/ui/demo/todo/Component.js
. So using /resources
should actually be correct if the app has a namespace. If there is no namespace (see
if (!project.metadata.namespace) { |
/
as prefix.
Also see handling in Builder:
ui5-builder/lib/builder/builder.js
Lines 320 to 324 in 438b210
getVirtualBasePathPrefix: function({project, virBasePath}) { | |
if (project.type === "application" && project.metadata.namespace) { | |
return projectBasePath; | |
} | |
}, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, I think we didn't supply "/resources" in the other ApplicationBuilder task's patterns since it doesn't matter for applications (there are no test-resources anyways). However, to prevent the user from having to specify "/resources" in their minification excludes we indeed need to apply the same prefix as for libraries: /resources/
.
Example for specifying component preload excludes in the openui5-sample-app:
builder:
componentPreload:
excludes:
- "sap/ui/demo/todo/"
test/lib/builder/builder.js
Outdated
@@ -1614,14 +1690,50 @@ const libraryJTree = { | |||
"configuration": { | |||
"paths": { | |||
"src": "main/src" | |||
} | |||
}, | |||
"propertiesFileSourceEncoding": "ISO-8859-1" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why this change?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks like I made copy&paste to the wrong object. Done.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fine with me if this also passed a manual test 🙂
Supports the build configuration "minification excludes"
introduced in specVersion 2.6. This allows to exclude
JavaScript resources from minification (tasks: uglify and
createDebugFiles).
JIRA: CPOUI5FOUNDATION-405