-
-
Notifications
You must be signed in to change notification settings - Fork 8k
Assets in <style> tags are not processed by vite build #5968
Copy link
Copy link
Closed
Labels
Description
Describe the bug
If I use, let’s say, an image in CSS using url() in a .css file, it works fine.
If I put the exact same styles inline in an HTML file using <style>, the assets are not copied to dist.
(Both variants work fine in dev mode.)
Reproduction
(Repro on Stackblitz, run npm run build.)
<!DOCTYPE html>
<style>
body {
background: url('/twitter.svg');
}
</style>
<h1>hai</h1>System Info
StackblitzUsed Package Manager
npm
Logs
❯ npm run build
$ vite build
vite v2.6.14 building for production...
✓ 1 modules transformed.
Generated an empty chunk: "index"
dist/index.html 0.14 KiB(Note the lack of twitter.svg)
### Validations
- [X] Follow our [Code of Conduct](https://github.com/vitejs/vite/blob/main/CODE_OF_CONDUCT.md)
- [X] Read the [Contributing Guidelines](https://github.com/vitejs/vite/blob/main/CONTRIBUTING.md).
- [X] Read the [docs](https://vitejs.dev/guide).
- [X] Check that there isn't [already an issue](https://github.com/vitejs/vite/issues) that reports the same bug to avoid creating a duplicate.
- [X] 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.
- [X] Check that this is a concrete bug. For Q&A open a [GitHub Discussion](https://github.com/vitejs/vite/discussions) or join our [Discord Chat Server](https://chat.vitejs.dev/).
- [X] The provided reproduction is a [minimal reproducible example](https://stackoverflow.com/help/minimal-reproducible-example) of the bug.
Reactions are currently unavailable