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.
- Read the docs.
- Make sure this is a Vite issue and not a framework-specific issue. For example, if it’s a Vue SFC related bug, it should likely be reported to https://github.com/vuejs/vue-next instead.
- This is a concrete bug. For Q&A open a GitHub Discussion or join our Discord Chat Server.
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
- Run
vite
orvite build
with the--debug
flag. - Provide the error log here.
Issue Analytics
- State:
- Created 2 years ago
- Reactions:1
- Comments:7 (2 by maintainers)
Top GitHub Comments
@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
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.