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.

Changes to external css file or external ts file used in svelte file does not trigger reload with HMR

See original GitHub issue

⚠️ IMPORTANT ⚠️ Please do not ignore this template. If you do, your issue will be closed immediately.

Describe the bug

A clear and concise description of what the bug is. Changes to external .css files or external .ts files configured as src documents in the svelte file does not trigger hot module reload. A save on the parent svelte file is required to trigger the update.

Inline style and script ts tags and code works as expected with hmr.

After testing on both a sveltekit@next and vite svelte ts template, I have narrowed down the issue to vite or vite - svelte-preprocessor integration.

Have tried to add css files to the vite.config.js server.watch options with a src/**/*.css glob.

// https://vitejs.dev/config/ export default defineConfig({ server: { watch: [ ‘src/**/*.css’ ] }, clear: false, plugins: [svelte()] })

See relevant log items below, vite shows that the change is recognized by watch but does not have a module to update even though the src attribute has the name.

Logs (Optional if provided reproduction)

vite:hmr [file change] src/_index.css +4m vite:hmr [no modules matched] src/_index.css +0m

<script lang="ts" src='_index.ts'/>
<style lang='sugarss' src='_index.css'/>

<!-- prettier-ignore -->
<template lang='pug'>
  div(class="m-title")
    .flex.item-center.justify-center
      | This is a test
</template>

Reproduction

_index.css - contents

 .m-title
   @apply text-7xl mt-[400px] text-indigo-800

Please provide a link to a repo that can reproduce the problem you ran into.

A reproduction is required unless you are absolutely sure that the the problem is obvious and the information you provided is enough for us to understand what the problem is. If a report has only vague description (e.g. just a generic error message) and has no reproduction, it will receive “need reproduction” label. If no reproduction is provided after 3 days, it will be auto-closed.

System Info

  • vite version: 2.1.0
  • Operating System: ubuntu 18.04
  • Node version: 14.13.0
  • Package manager (npm/yarn/pnpm) and version: yarn 1.22.5

Logs (Optional if provided reproduction)

vite:hmr [file change] src/_index.css +4m vite:hmr [no modules matched] src/_index.css +0m

  1. Run vite or vite build with the --debug flag.
  2. Provide the error log here.

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Reactions:1
  • Comments:7 (2 by maintainers)

github_iconTop GitHub Comments

2reactions
NiQ-Bcommented, Mar 22, 2021

@jacobclevenger thank you for the quick response. Here is a link to the public repo. I added a plugin to do hmr login as well.
https://github.com/NiQ-B/test-vite

1reaction
bluwycommented, Dec 14, 2021

Thanks for the update @ambrt. @NiQ-B haven’t responded in a while, and I can’t reproduce this, so I’ll go ahead and close this issue.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Windi CSS HMR not working for Svelte + vite app
But HMR (Hot Module Reload) for Windi CSS does not work. But when I kill the server and restart it picks up the...
Read more >
Configuring Vitest
Use experimental Node loader to resolve imports inside externalized files, using Vite resolve algorithm. If disabled, your alias and <plugin>.
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 >
Hot reload | NestJS - A progressive Node.js framework
Nest is a framework for building efficient, scalable Node.js server-side applications. It uses progressive JavaScript, is built with TypeScript and combines ...
Read more >
Hot Module Replacement - webpack
HMR is not intended for use in production, meaning it should only be used in ... Now let's update the index.js file so...
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