Elderjs / elderjs

Elder.js is an opinionated static site generator and web framework for Svelte built with SEO in mind.

Home Page:https://elderguide.com/tech/elderjs/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Changes from @import-ed CSS files are not applied

kucrut opened this issue · comments

Even after reloading the browser, changes from CSS files that are @import-ed from <style> tags are not applied, until the svelte file is saved. I can confirm that the issue is happening on MacOS & (Arch) Linux.

Below is a video demonstrating it on vanilla Elder template.

elder-css-changes-not-applied.mp4
commented

I think the @import statement is processed by clean-css:

const cleanCss = new CleanCSS({
sourceMap: true,
sourceMapInlineSources: true,
level: isDev ? 0 : 1,
rebaseTo: elderConfig.distDir,
// rebase: elderConfig.distDir,
});
const sorted = sortCss(css);
return {
...cleanCss.minify(sorted),
included: sorted ? sorted.map((m) => Object.keys(m)[0]) : [],
};

Which is called after the build.

To fix this, we have to process @import statement in the transform function and set imported files as dependencies.