Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

shaungbhone's avatar

Vite assets bundling in Inertia

I got an error [plugin:vite:import-analysis] import.meta.glob() can only accept string literals. when I added vite asset URL helper.

import.meta.glob([
  '../images/**',
  '../fonts/**',
]);

So I changed it like this.

import.meta.glob(
    '../images/**'
);

Error is Uncaught SyntaxError: Unexpected token ':' (at app.js:8:31)

The compile file app.js show me.

{ "../images/about-banner.png": () => import("/resources/images/about-banner.png?import"),

Reference

github issues

0 likes
4 replies
Sinnbeck's avatar
Sinnbeck
Best Answer
Level 102

Are you sure you are running vite 3.x and the plugin is up to date?

npm update
1 like
shaungbhone's avatar

@Sinnbeck Thank you. I didn't know when vite 3 is out xd? it's working but not found png. Url gives me like this. http://0.0.0.0:5173/@fs/resources/js/resources/images/dot.png when I call

<script setup>
import dot from "@/resources/images/dot.png";
</script>

I think that comes from jsconfig.js

"paths": {
            "@/*": ["resources/js/*"],
        },

So, I removed the '@' is that okay?

<script setup>
import dot from "/resources/images/dot.png";
</script>

Please or to participate in this conversation.