Skip to content

Commit

Permalink
[FEATURE] Add build flag "--experimental-css-variables" (#501)
Browse files Browse the repository at this point in the history
Enables UI5 builds with CSS Variables.
BLI: CPOUI5FOUNDATION-346
  • Loading branch information
flovogt committed Apr 5, 2022
1 parent 0b84c73 commit 0b099db
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 3 deletions.
14 changes: 12 additions & 2 deletions lib/cli/commands/build.js
Expand Up @@ -100,6 +100,13 @@ build.builder = function(cli) {
describe: "Overrides the framework version defined by the project",
type: "string"
})
.option("experimental-css-variables", {
describe:
"If present, the CSS variables (css-variables.css, css-variables.source.less) " +
"and the skeleton for a theme (library-skeleton.css, [library-skeleton-RTL.css]) are generated",
default: false,
type: "boolean"
})
.example("ui5 build", "Preload build for project without dependencies")
.example("ui5 build self-contained --all", "Self-contained build for project including dependencies")
.example("ui5 build --all --exclude-task=* --include-task=createDebugFiles generateAppPreload",
Expand All @@ -111,7 +118,9 @@ build.builder = function(cli) {
"Build project and dependencies in dev mode, except \"sap.ui.core\" and \"sap.m\" " +
"(useful in combination with --include-task)")
.example("ui5 build dev",
"Build project and dependencies in dev mode. Only a set of essential tasks is executed.");
"Build project and dependencies in dev mode. Only a set of essential tasks is executed.")
.example("ui5 build --experimental-css-variables",
"Preload build for project without dependencies but with CSS variable artefacts");
};

async function handleBuild(argv) {
Expand Down Expand Up @@ -162,7 +171,8 @@ async function handleBuild(argv) {
jsdoc: command === "jsdoc",
devExcludeProject: argv["dev-exclude-project"],
includedTasks: argv["include-task"],
excludedTasks: argv["exclude-task"]
excludedTasks: argv["exclude-task"],
cssVariables: argv["experimental-css-variables"]
});
}

Expand Down
21 changes: 20 additions & 1 deletion test/lib/cli/commands/build.js
Expand Up @@ -31,7 +31,8 @@ const defaultBuilderArgs = {
jsdoc: false,
devExcludeProject: undefined,
includedTasks: undefined,
excludedTasks: undefined
excludedTasks: undefined,
cssVariables: undefined
};

test.beforeEach((t) => {
Expand Down Expand Up @@ -487,3 +488,21 @@ test.serial("ui5 build --include-dependency (dependency not found)", async (t) =
["Could not find dependency \"sap.ui.core\" for project Sample. Dependency filter is ignored"],
"logger.warn should be called with expected string");
});


test.serial("ui5 build --experimental-css-variables", async (t) => {
normalizerStub.resolves({
metadata: {
name: "Sample"
},
dependencies: []
});
args._ = ["build"];
args["experimental-css-variables"] = true;
await t.context.build.handler(args);
t.deepEqual(
builderStub.getCall(0).args[0],
Object.assign({}, defaultBuilderArgs, {cssVariables: true}),
"Build with activated CSS Variables is called with expected arguments"
);
});

0 comments on commit 0b099db

Please sign in to comment.