Skip to content
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

Add a dev build script for @wso2is/theme #2569

Merged
merged 1 commit into from
Oct 5, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions modules/theme/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
"scripts": {
"prebuild": "npm run clean",
"build": "npm run compile -- --skipSample --skipManifest",
"build:dev": "npm run build -- --skipHashing",
"clean": "rimraf ./dist && rimraf ./src/themes/sample",
"compile": "node scripts/build.js",
"watch": "watch \"npm run build\" src"
Expand Down
15 changes: 11 additions & 4 deletions modules/theme/scripts/build.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ const MANIFEST_FILE_NAME = "assets-manifest.json";

const skipSample = process.argv.indexOf("--skipSample") > -1; // CLI arg to skip the sample theme generation.
const skipManifest = process.argv.indexOf("--skipManifest") > -1; // CLI arg to skip the asset manifest generation.
const skipHashing = process.argv.indexOf("--skipHashing") > -1; // CLI arg to skip the hashing the css artifacts.

/*
* Generate Default Site Variables JSON files
Expand Down Expand Up @@ -206,13 +207,19 @@ const generateThemes = () => {
};

Object.keys(files).map((key) => {
const hash = files[ key ] && crypto.createHash("sha1").update(files[ key ]).digest("hex");
const ext = hash
? `.${ hash.substr(0, 8) }${ key }`
: key;

let ext = key;

if (!skipHashing) {
const hash = files[ key ] && crypto.createHash("sha1").update(files[ key ]).digest("hex");
ext = hash
? `.${ hash.substr(0, 8) }${ key }`
: key;
}

writeFile(theme, ext, files[ key ], themeIndexFile);
});

copyAssets(theme, filePath);

if (!skipManifest) {
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
"scripts": {
"bootstrap": "npm install && npx lerna bootstrap",
"bootstrap:hoist": "npm install && npx lerna bootstrap --hoist --no-ci",
"build:dev": "npm run bootstrap && npm run build",
"build:dev": "npm run bootstrap && npm run build -- --ignore @wso2is/theme && npx lerna run build:dev --stream --scope @wso2is/theme",
"build": "npx lerna run build --stream",
"build:apps": "npx lerna run build --stream --scope '{@wso2is/myaccount,@wso2is/console}'",
"build:modules": "npx lerna run build --stream --scope '{@wso2is/core,@wso2is/forms,@wso2is/form,@wso2is/i18n,@wso2is/react-components,@wso2is/theme,@wso2is/validation}'",
Expand Down