Closed cewald closed 1 year ago
This is my vite.config.ts
:
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 index.html
production output:
<!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 3.4.1-beta.0
.
Could you please try it and get back to me?
I tested it and it works in dev and production mode, using injectAsStyleTag
and without.
That was quick – thank you!
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#L285The
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#L312Any experience with that – shouldn't this be considered?