From 064946614dd667498f6cdf45012e26045bd2fa08 Mon Sep 17 00:00:00 2001 From: Dominik Feininger Date: Mon, 3 Apr 2023 12:59:56 +0200 Subject: [PATCH 1/3] feat: livecompile for less --- packages/ui5-middleware-livecompileless/lib/index.js | 8 +++++++- packages/ui5-middleware-livereload/lib/livereload.js | 2 +- packages/ui5-middleware-livereload/package.json | 2 +- 3 files changed, 9 insertions(+), 3 deletions(-) diff --git a/packages/ui5-middleware-livecompileless/lib/index.js b/packages/ui5-middleware-livecompileless/lib/index.js index 8d039577c..56d4b7a07 100644 --- a/packages/ui5-middleware-livecompileless/lib/index.js +++ b/packages/ui5-middleware-livecompileless/lib/index.js @@ -22,7 +22,13 @@ module.exports = async ({ resources, options }) => { return async function injectLess(req, res, next) { let url = req.url; if (url.includes(".css") && !url.includes("resources/")) { - let possibleLessFile = await resources.rootProject.byPath(url.replace(".css", ".less")); + // in case of livereload a `?livereload=` will be appended + let lessUrl = url.replace(".css", ".less"); + if (lessUrl.includes("?")) { + lessUrl = lessUrl.substr(0, lessUrl.indexOf("?")); + } + + let possibleLessFile = await resources.rootProject.byPath(lessUrl); if (possibleLessFile) { isDebug && log.info(`Compiling ${possibleLessFile.getPath()}...`); const lessBuilder = new less.Builder({ fs: fsInterface(resources.all) }); diff --git a/packages/ui5-middleware-livereload/lib/livereload.js b/packages/ui5-middleware-livereload/lib/livereload.js index 3459eda7d..278462be2 100644 --- a/packages/ui5-middleware-livereload/lib/livereload.js +++ b/packages/ui5-middleware-livereload/lib/livereload.js @@ -88,7 +88,7 @@ module.exports = async ({ resources, options }) => { } else if (exclusions) { exclusions = [new RegExp(exclusions)]; } - let extraExts = options?.configuration?.extraExts || "jsx,ts,tsx,xml,json,properties"; + let extraExts = options?.configuration?.extraExts || "jsx,ts,tsx,xml,json,properties,less"; let debug = options?.configuration?.debug; let usePolling = options?.configuration?.usePolling; diff --git a/packages/ui5-middleware-livereload/package.json b/packages/ui5-middleware-livereload/package.json index eb2da49b3..93c831907 100644 --- a/packages/ui5-middleware-livereload/package.json +++ b/packages/ui5-middleware-livereload/package.json @@ -15,7 +15,7 @@ "dependencies": { "@ui5/logger": "^2.0.1", "connect-livereload": "^0.6.1", - "livereload": "^0.9.3", + "livereload": "git@github.com:dominikfeininger/node-livereload.git", "portfinder": "^1.0.32", "yargs": "^17.7.1" }, From 5371e9ed5324ee93335ad1d5e972c09295609f7e Mon Sep 17 00:00:00 2001 From: Dominik Feininger Date: Mon, 3 Apr 2023 21:37:02 +0200 Subject: [PATCH 2/3] feat: livecompile for less --- packages/ui5-middleware-livereload/package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/ui5-middleware-livereload/package.json b/packages/ui5-middleware-livereload/package.json index 93c831907..3dd87684e 100644 --- a/packages/ui5-middleware-livereload/package.json +++ b/packages/ui5-middleware-livereload/package.json @@ -15,7 +15,7 @@ "dependencies": { "@ui5/logger": "^2.0.1", "connect-livereload": "^0.6.1", - "livereload": "git@github.com:dominikfeininger/node-livereload.git", + "livereload": "git+ssh://git@github.com:dominikfeininger/node-livereload.git", "portfinder": "^1.0.32", "yargs": "^17.7.1" }, From 2bc15050973d3135fa5c0592d14194f22e956a6d Mon Sep 17 00:00:00 2001 From: Dominik Feininger Date: Thu, 20 Apr 2023 09:12:13 +0200 Subject: [PATCH 3/3] chore: update pnpm-lock --- pnpm-lock.yaml | 49 ++++++++++++++++++++++++++----------------------- 1 file changed, 26 insertions(+), 23 deletions(-) diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 118ceaed2..b58c2a173 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -148,8 +148,8 @@ importers: specifier: ^0.6.1 version: 0.6.1 livereload: - specifier: ^0.9.3 - version: 0.9.3 + specifier: git+ssh://git@github.com:dominikfeininger/node-livereload.git + version: github.com/dominikfeininger/node-livereload/43bf983a7bb602cbdc2282422a5d777d753ec1d5 portfinder: specifier: ^1.0.32 version: 1.0.32 @@ -5440,7 +5440,7 @@ packages: /axios@1.3.5: resolution: {integrity: sha512-glL/PvG/E+xCWwV8S6nCHcrfg1exGx7vxyUIivIA1iL7BIh6bePylCfVHwp6k13ao7SATxB6imau2kqY+I67kw==} dependencies: - follow-redirects: 1.15.2(debug@4.3.2) + follow-redirects: 1.15.2(debug@4.3.4) form-data: 4.0.0 proxy-from-env: 1.1.0 transitivePeerDependencies: @@ -8664,7 +8664,6 @@ packages: optional: true dependencies: debug: 4.3.4(supports-color@8.1.1) - dev: false /for-each@0.3.3: resolution: {integrity: sha512-jqYfLp7mo9vIyQf8ykW2v7A+2N4QjeCeI5+Dz9XraiO1ign81wjiH7Fb9vSOWvQfNtmSa4H2RoQTrrXivdUZmw==} @@ -9528,7 +9527,7 @@ packages: engines: {node: '>=8.0.0'} dependencies: eventemitter3: 4.0.7 - follow-redirects: 1.15.2(debug@4.3.2) + follow-redirects: 1.15.2(debug@4.3.4) requires-port: 1.0.0 transitivePeerDependencies: - debug @@ -10999,24 +10998,6 @@ packages: wrap-ansi: 7.0.0 dev: true - /livereload-js@3.4.1: - resolution: {integrity: sha512-5MP0uUeVCec89ZbNOT/i97Mc+q3SxXmiUGhRFOTmhrGPn//uWVQdCvcLJDy64MSBR5MidFdOR7B9viumoavy6g==} - dev: false - - /livereload@0.9.3: - resolution: {integrity: sha512-q7Z71n3i4X0R9xthAryBdNGVGAO2R5X+/xXpmKeuPMrteg+W2U8VusTKV3YiJbXZwKsOlFlHe+go6uSNjfxrZw==} - engines: {node: '>=8.0.0'} - hasBin: true - dependencies: - chokidar: 3.5.3 - livereload-js: 3.4.1 - opts: 2.0.2 - ws: 7.5.9 - transitivePeerDependencies: - - bufferutil - - utf-8-validate - dev: false - /load-json-file@1.1.0: resolution: {integrity: sha512-cy7ZdNRXdablkXYNI049pthVeXFurRyb9+hA/dZzerZ0pGTx42z+y+ssxBaVV2l70t1muq5IdKhn4UtcoGUY9A==} engines: {node: '>=0.10.0'} @@ -16529,3 +16510,25 @@ packages: compress-commons: 4.1.1 readable-stream: 3.6.2 dev: true + + github.com/dominikfeininger/livereload-js/07c98e90dedc37c89f99f131ed0a281c0b3a055a: + resolution: {tarball: https://codeload.github.com/dominikfeininger/livereload-js/tar.gz/07c98e90dedc37c89f99f131ed0a281c0b3a055a} + name: livereload-js + version: 4.0.1 + dev: false + + github.com/dominikfeininger/node-livereload/43bf983a7bb602cbdc2282422a5d777d753ec1d5: + resolution: {tarball: https://codeload.github.com/dominikfeininger/node-livereload/tar.gz/43bf983a7bb602cbdc2282422a5d777d753ec1d5} + name: livereload + version: 0.9.3 + engines: {node: '>=8.0.0'} + hasBin: true + dependencies: + chokidar: 3.5.3 + livereload-js: github.com/dominikfeininger/livereload-js/07c98e90dedc37c89f99f131ed0a281c0b3a055a + opts: 2.0.2 + ws: 7.5.9 + transitivePeerDependencies: + - bufferutil + - utf-8-validate + dev: false