Closed schelmo closed 7 months ago
Start a new pull request in StackBlitz Codeflow.
Actually I am having this problem with publicDir
left at its default setting. This code works fine in 5.0.12 but breaks in 5.1:
import pdfMake from "pdfmake/build/pdfmake";
import "@fontsource/source-sans-pro/latin-400.css"
import "@fontsource/source-sans-pro/latin-400-italic.css"
import "@fontsource/source-sans-pro/latin-700.css"
import "@fontsource/source-sans-pro/latin-700-italic.css"
pdfMake.fonts = {
SourceSans: {
normal: new URL("../../node_modules/@fontsource/source-sans-pro/files/source-sans-pro-latin-400-normal.woff", import.meta.url).href,
bold: new URL("../../node_modules/@fontsource/source-sans-pro/files/source-sans-pro-latin-700-normal.woff", import.meta.url).href,
italics: new URL("../../node_modules/@fontsource/source-sans-pro/files/source-sans-pro-latin-400-italic.woff", import.meta.url).href,
bolditalics: new URL("../../node_modules/@fontsource/source-sans-pro/files/source-sans-pro-latin-700-italic.woff", import.meta.url).href,
},
};
Output:
vite v5.1.4 building for production...
transforming (1) resources/js/user.js
new URL("../../node_modules/@fontsource/source-sans-pro/files/source-sans-pro-latin-400-normal.woff", import.meta.url) doesn't exist at build time, it will remain unchanged to be resolved at runtime
new URL("../../node_modules/@fontsource/source-sans-pro/files/source-sans-pro-latin-700-normal.woff", import.meta.url) doesn't exist at build time, it will remain unchanged to be resolved at runtime
new URL("../../node_modules/@fontsource/source-sans-pro/files/source-sans-pro-latin-400-italic.woff", import.meta.url) doesn't exist at build time, it will remain unchanged to be resolved at runtime
new URL("../../node_modules/@fontsource/source-sans-pro/files/source-sans-pro-latin-700-italic.woff", import.meta.url) doesn't exist at build time, it will remain unchanged to be resolved at runtime
✓ 659 modules transformed.
@miken32 may it be that you don't have a public directory in your project?
@schelmo I do indeed, it's a Laravel project.
ok then this is the same issue because laravel sets the publicDir default to false: https://github.com/laravel/vite-plugin/blob/dace190f626b5d67dc32958d435701efa9615b42/src/index.ts#L142
the same issue in laravel project
Describe the bug
When you have set
publicDir
to false and building urls withIn vite 5.0.x this worked. but since vite 5.1, this doesn't work anymore.
my guess the relevant part is here: https://github.com/vitejs/vite/blob/b20d54257e6105333c19676a403c574667878e0f/packages/vite/src/node/plugins/assetImportMetaUrl.ts#L124 i tried to rewrite it to
but it seems tha
publicDir
is set to an empty string.Reproduction
https://stackblitz.com/edit/vitejs-vite-ggxiek?file=main.js
Steps to reproduce
Run
npm install
then runnpm run build
to the see log entrySystem Info
Used Package Manager
npm
Logs
Click to expand!
```shell new URL('./javascript.svg', import.meta.url) doesn't exist at build time, it will remain unchanged to be resolved at runtime ```Validations