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.

using csz's file import in snowpack setup breaks the dev server's hmr.

See original GitHub issue

i have put this question on pika discuss forum as well. putting it here as i think its intertwined with snowpack’s way of importing css files. i have one component.css file which i am importing like this in component.tsx file.

const componentStyle = css`/component.css`

// usage
<div className={componentStyle}>
// ..some html here//
</div>

since this css file is not imported using top level import but is inside csz’s template literal. any changes made to this landing.css file doesn’t reflect … i have to restart the snowpack’s dev server to see the new changes. i explored my sources tab in chrome’s console tool. since snowpack didn’t encountered any import of css file it was not served and hence this doesn’t work. but some where down the line csz’s framework takes care of that adding the style to the dom. i am not sure this is the ideal scenario for snowpack to pick up file (which is not imported using import but is inside css string literal )and serve it. is there a setup or repo which i can use it as a reference where csz is used in a snowpack setup and also css files are imported in .jsx/.tsx files.

Issue Analytics

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

github_iconTop GitHub Comments

1reaction
lukejacksonncommented, Jul 23, 2020

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!

1reaction
Manish3323commented, Jul 22, 2020

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.

Read more comments on GitHub >

github_iconTop Results From Across the Web

dev server performance in large projects #1269 - GitHub
Hello,. I love the development experience with snowpack but I have a few questions/issues/ideas. Http2 does not seem to work in dev. All...
Read more >
snowpack.config.js
Used for installing packages any dependencies that cannot be detected by our automatic import scanner (ex: package CSS files). packageOptions.polyfillNode#.
Read more >
Snowpack Hot Module Replacement (HMR) from scratch with ...
First, set up your project folder and initialise it as a Node project. mkdir snowpack-hmr cd snowpack-hmr npm init -f. Next, install Snowpack....
Read more >
Vite.js Next Generation Frontend Tooling + Craft CMS
This article shows you how to integrate Vite.js with Craft CMS ... you will be using Vite dev server for hot module replacement...
Read more >
What is Vitejs? An Overview of the New Front-end Build Tool
Need a simpler way to set up a front-end dev environment? With Vite, you can be up and running with Vue, React and...
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