-
Notifications
You must be signed in to change notification settings - Fork 11
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Missing CSS in production because indexHtmlPath
isn't correctly stripped
#18
Comments
cewald
changed the title
Missing CSS in production because Nov 3, 2022
indexHtmlPath
isn't correct when base
is not /
indexHtmlPath
isn't correctly stripped
This is my import { fileURLToPath, URL } from 'node:url'
import { defineConfig } from 'vite'
import vue from '@vitejs/plugin-vue'
import vueJsx from '@vitejs/plugin-vue-jsx'
import webfontDownload from 'vite-plugin-webfont-dl'
import svgLoader from 'vite-svg-loader'
import Icons from 'unplugin-icons/vite'
// https://vitejs.dev/config/
export default defineConfig({
base: '/cv/',
plugins: [
vue(),
vueJsx(),
svgLoader(),
Icons({}),
webfontDownload(
[
'https://fonts.googleapis.com/css2?family=Roboto:wght@400;500&display=swap',
'https://fonts.googleapis.com/css2?family=Roboto+Mono:wght@400;700&display=swap'
],
{}
)
],
resolve: {
alias: {
'@': fileURLToPath(new URL('./src', import.meta.url))
}
},
server: {
port: 3000
}
}) And this it the <!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<link rel="icon" href="/cv/favicon.ico">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>...</title>
<script type="module" crossorigin src="/cv/assets/index.27d05be5.js"></script>
<link rel="stylesheet" href="/cv/assets/index.23033122.css">
</head>
<body>
<div id="app"></div>
</body>
</html> |
Thank @cewald for raising this issue! I've just created a fix and released |
I tested it and it works in dev and production mode, using |
Thank you! I've just published |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I'm having trouble with the production build when the public-base-path of vite isn't the default one. The style-tag nor the CSS file (if
injectAsStyleTag
isfalse
) is injected. It works fine if I use the defaultbase
config in myvite.config.js
.I had a look at the code and saw that there is a replace of the path for the
indexHtmlPath
variable which on default replaces the trailing/
of theindex.html
path, but won't replace it properly if the base isn't just/
.https://github.com/feat-agency/vite-plugin-webfont-dl/blob/master/src/index.ts#L285
The
generateBundle
method then won't find theindex.html
file in thebundle
array:https://github.com/feat-agency/vite-plugin-webfont-dl/blob/master/src/index.ts#L312
Any experience with that – shouldn't this be considered?
The text was updated successfully, but these errors were encountered: