Comments (6)
Sure thing.
i have put this same question on pika discuss also .i'm sure the moderators will have say in this. meanwhile i'll learn about es-module-shims.
from csz.
Ahh cool. So maybe my assumptions about HMR getting all its graph data from parsing code wasn't correct then 😅
Regards relative links, it wasn't really a choice either! This was due to lack of support for import.meta
which allows you to infer the location of the location of the calling script. From there you can build up relative paths.
Until then I think we are stuck with absolute links.. but I would be interesting in seeing an implementation ready for when import meta is standardised!
from csz.
Hey 👋 thanks for investigating this!
Unfortunately this is a side effect of HMR relying on getting its file graph data from parsing actual imports (which is generally a good thing) and csz using a completely custom import syntax (uses template literal and fetch instead, as importing css is not yet supported by the browser).
I'm not sure what to suggest here, until dynamic import of CSS becomes standard then we have to think of a call for an external file like this as a fetch request (which wouldn't normally cause a refresh).
Does refreshing the page not cause the styles to update. Unless HMR is caching fetch requests then you shouldn't have to restart the server entirely. Not an idea solution I know, but slightly better!
from csz.
Thanks for replying quickly.
unfortunately refreshing browser doesn't work :(
however i will check this, if there's a way to configure snowpack to cache fetch request.
Nice little library though. very impressive work!! 💯
from csz.
No worries! It is an interesting problem.. I know that there is a shim for css imports in https://github.com/guybedford/es-module-shims but I am not sure how that will play with snowpacks build either 🤷♂️
Let me know if you get to the bottom of it.. otherwise perhaps we can consult one of the snowpack folk or my colleague who implemented the hot module reloading for snowpack.
from csz.
okay.. i feel bit embarrassed now. found that the problem is something unrelated to csz and snowpack. the initials of folder were css are located were in capital n i had put lowercase folder. 🙈 🤦♂️
this raises another question in my mind. if csz could handle relative imports, problems like i had would be less likely to happen.if there's a way to put relative path inside csz's string literal .. as in large projects where components can be situated deep inside folder structures, developer will not have to put full absolute path like this
const style = css`/_dist_/components/Landing/Landing.css`
but instead have something like this
const style = css`/./Landing.css`
first slash is necessary i guess to distinguish the inline css and css file.
ill give a try to incorporate relative imports in csz and send a PR. unless they were some reasons which restricted you to have relative imports in first place.
from csz.
Related Issues (7)
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from csz.