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

Livereload for less #709

Draft
wants to merge 4 commits into
base: main
Choose a base branch
from
Draft
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
8 changes: 7 additions & 1 deletion packages/ui5-middleware-livecompileless/lib/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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=<timestamp>` 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) });
Expand Down
2 changes: 1 addition & 1 deletion packages/ui5-middleware-livereload/lib/livereload.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
2 changes: 1 addition & 1 deletion packages/ui5-middleware-livereload/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
"dependencies": {
"@ui5/logger": "^2.0.1",
"connect-livereload": "^0.6.1",
"livereload": "^0.9.3",
"livereload": "git+ssh://[email protected]:dominikfeininger/node-livereload.git",
"portfinder": "^1.0.32",
"yargs": "^17.7.1"
},
Expand Down
49 changes: 26 additions & 23 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.