From 0054e2334637796061b75b938b9cbfb41c29389c Mon Sep 17 00:00:00 2001 From: Brion Mario Date: Tue, 5 Oct 2021 18:26:18 +0530 Subject: [PATCH] Add a dev build script for `@wso2is/theme` --- modules/theme/package.json | 1 + modules/theme/scripts/build.js | 15 +++++++++++---- package.json | 2 +- 3 files changed, 13 insertions(+), 5 deletions(-) diff --git a/modules/theme/package.json b/modules/theme/package.json index 0dde0a2889c..203c14e6c35 100644 --- a/modules/theme/package.json +++ b/modules/theme/package.json @@ -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" diff --git a/modules/theme/scripts/build.js b/modules/theme/scripts/build.js index 538fa00321b..4b1ca1a9716 100644 --- a/modules/theme/scripts/build.js +++ b/modules/theme/scripts/build.js @@ -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 @@ -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) { diff --git a/package.json b/package.json index ae3e29fc50b..95993287d6a 100644 --- a/package.json +++ b/package.json @@ -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}'",