Giter Site home page Giter Site logo

Comments (2)

logue avatar logue commented on May 24, 2024

This is a Vite question.

I think it's because the address resolution isn't working.

In general, the front end cannot scan files in a specific directory on the server. If you're thinking of implementing a script that updates the file list in the directory on the frontend side, using import.meta.glob is not the right solution. It is common to prepare a backend program that outputs a list of files in a directory and obtain it with axios or Fetch API.

from vite-vuetify-ts-starter.

itsgifnotjiff avatar itsgifnotjiff commented on May 24, 2024

I did figure it out, Vite needs to resolve paths for static assets from absolute paths so in my case I had to remove the base from vite.config.js and adapt my code to produce an absolute path which looks something like :

(Object.values(import.meta.glob("../assets/ss_content/tu_et_moi/*.{jpg,png,gif}", { eager: true }))).forEach(
        ({ default: path }: any) => {
            const url = new URL(path, import.meta.url);
            const data = {
                src: url.pathname,
                alt: 'Alt_' + path
            };
            tuEtMoiImages.push(data);
        }
    );

from vite-vuetify-ts-starter.

Related Issues (14)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.