vite build
fails when using build.rollupOptions.external together with <link rel="stylesheet">
#6931
Closed
7 tasks done
Labels
Describe the bug
If the build.rollupOptions.external config option includes a CSS file as a path, a
<link rel="stylesheet">
tag matching that path is incorrectly removed from theindex.html
file and inserted into the JS file, breaking the result as it's then left there asimport "...css"
by Rollup due to the external config. This only affects the production build, as in dev mode the<link>
is left intact and works as expected.In the code, this looks like the culprit:
vite/packages/vite/src/node/plugins/html.ts
Lines 216 to 220 in e8c840a
vite/packages/vite/src/node/plugins/html.ts
Lines 324 to 331 in e8c840a
I'm willing to file a PR fixing this, if it's okay to introduce a dependency in
buildHtmlPlugin()
on the value of the build.rollupOptions.external config option?Reproduction
https://gist.github.com/eemeli/97b34dc72c886dffa25168699fe81e79
System Info
System: OS: macOS 12.1 CPU: (8) arm64 Apple M1 Memory: 73.81 MB / 16.00 GB Shell: 5.8 - /bin/zsh Binaries: Node: 17.4.0 - /opt/homebrew/bin/node Yarn: 1.22.11 - /opt/homebrew/bin/yarn npm: 8.3.1 - /opt/homebrew/bin/npm Browsers: Chrome: 98.0.4758.80 Firefox: 96.0.3 Safari: 15.2 npmPackages: vite: ^2.8.0 => 2.8.2
Used Package Manager
npm
Logs
No response
Validations
The text was updated successfully, but these errors were encountered: