question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Routify doesn't catch changes in global.css

See original GitHub issue

If I add a rule to global.css, save, and refresh the page, it doesn’t work.

Steps to reproduce

git clone https://github.com/Wolfr/hn-clone-svelte-be.git
npm i
npm run dev

Go to global.css. Add a rule like

* {
  background: yellow;
}

Observe that no change happens.

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:6 (1 by maintainers)

github_iconTop GitHub Comments

2reactions
Wolfrcommented, Mar 10, 2020

Using style tags in Svelte files works for small demos and small projects.

The Svelte provided CSS scoping is super nice for exceptions to the general rule in bigger projects and for quick coding of experiments.

The reason to have a separate CSS architecture is

  1. to be able to use SCSS in its full capacitiy (that is a system where theme variables can traverse through in full) without hacky workarounds
  2. to be able to use established conventions such as BEM and ITCSS (see Harry Roberts’s work on this which is absolutely great - it is difficult to explain in a sentence)
  3. to be able to use the exact same codebase CSS-wise, regardless of the Javascript framework (we have plenty of projects that provide a CSS base for projects in Angular, PHP and React at the same time)

For example, we use the exact same SCSS in our Wordpress version as in our current Svelte version. There’s some definite business benefits in maintaining proper CSS as a separate “thing”.

0reactions
jakobrosenbergcommented, Mar 10, 2020

@Wolfr I’m going off topic here, but is there a reason you don’t use <style> tags in .svelte files? Not a suggestion. Just curiosity.

global.css is a bit of a static file to me. Like an asset. If it were to be used as a dynamic source file instead, it would make more sense to me to import it in main.js.

In general code should act as one would expect, but what happens when people have different expectations or even wrong expectations. I think the best way to handle these scenarios, is by showing a correct approach.

IMO the current structure reflects what can be expected of Rollup. Files in the static folder are static and changing them won’t cause an update. As often seen in other projects, we could create a src/assets folder for css/scss and import it in App.svelte. This keeps things simple in the sense that src is for dynamic content.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Editing global.css doesn't work · Issue #32 - GitHub
Expected behavior. File is copied over to /dist/global.css with changes. Current result. Nothing happens. The watcher doesn't seem to catch the file change....
Read more >
FAQ - Routify
How do I use Routify with Electron? Electron doesn't detect changes in node_modules. To get around that, we can export the generated files...
Read more >
Svelte (routify) + rollup: not watching for css changes in /static
I want to be able to watch for changes in /static (for example, on global.css). I am using the following code to watch...
Read more >
Svelte SPA routing: Routify tutorial - YouTube
How to use Routify with Svelte for client-side (SPA) routing. Source code: https://bitbucket.org/spinspire/svelte- routify -demo/Index/TOC:00: ...
Read more >
2.23 - Routes for Svelte with Routify - YouTube
Jake Rosenberg and Willow join us to talk about Routes for Svelte with ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found