-
Notifications
You must be signed in to change notification settings - Fork 58
Open
Description
I follow this doc in vite: https://vite.dev/config/shared-options.html#css-postcss
And I want to change the font file path in css after build.
before:
@font-face {
font-family: iconfont;
src:
url("./assets/fonts/iconfont.woff2?t=1722856322648") format("woff2"),
url("./assets/fonts/iconfont.woff?t=1722856322648") format("woff"),
url("./assets/fonts/iconfont.ttf?t=1722856322648") format("truetype");
}after, I want this
@font-face {
font-family: iconfont;
src:
url("../assets/fonts/iconfont.woff2?t=1722856322648") format("woff2"),
url("../assets/fonts/iconfont.woff?t=1722856322648") format("woff"),
url("../assets/fonts/iconfont.ttf?t=1722856322648") format("truetype");
}this is my config:
css: {
postcss: {
plugins: [
postcssUrl({
url: (asset) => {
if (!/\.(woff|woff2|ttf)$/.test(asset.pathname || '')) {
return asset.url;
}
// ensure paths are correct in npm publish
return `../assets/fonts/${asset.url.split('/').pop()}`;
},
}),
],
},But the result is
@font-face{font-family:iconfont;src:url(data:font/woff2;base64,d09GMgABAAAAAAQw
If I understand correctly, it uses inline mode internally, and I want to use a relative path string, so how can I make it use rebase mode?
By the way, I did something similar in rollup, and I did find that it defaulted to rebase mode, which was different from the result of vite.
skeller-mereo
Metadata
Metadata
Assignees
Labels
No labels