Giter Club home page Giter Club logo

Comments (4)

poppa avatar poppa commented on July 29, 2024 1

When you use this plugin the SVGs you import should rather reside within your "source" folder. Note that when used like this the SVGs are more or less compile-time resources rather than runtime resources, hence why you shouldn't put resources used by this plugin in the static folder.

from sveltekit-svg.

poppa avatar poppa commented on July 29, 2024

Correct me if I'm wrong, but this is a warning and not an error, right?

From what I can tell this is a warning from Vite so this seems like something I can't fix in the plugin. I managed to find this deep inside Vite:

// check if public dir is inside root dir
const publicDir = normalizePath$4(server.config.publicDir);
const rootDir = normalizePath$4(server.config.root);
if (publicDir.startsWith(rootDir)) {
    const publicPath = `${publicDir.slice(rootDir.length)}/`;
    // warn explicit public paths
    if (url.startsWith(publicPath)) {
        logger.warn(source.yellow(`files in the public directory are served at the root path.\n` +
            `Instead of ${source.cyan(url)}, use ${source.cyan(url.replace(publicPath, '/'))}.`));
    }
}

My reading of this is that you either have to live with the warning, or simply move the SVG you'r importing as a component within your source directory.

Also, this warning only seems to occur when running svelte-kit dev.

Unless you provide some further info about this problem (Svelte version, adapter type, is it dev/prod mode, is it building correctly or not, etc...) I will close this issue in a couple of days.

Thanks for the report nonetheless.

from sveltekit-svg.

DanielRios549 avatar DanielRios549 commented on July 29, 2024

Ok, it definitely seems to be a development warning only, when the project is built, it put the SVG inline in HTML and the warning does not accours.

I am using SvelteKit in next version (at least this is what it says in package.json), and the adapter-static to build. Using this adapter, I think there is no need of put the SVGs inside static folder.

from sveltekit-svg.

DanielRios549 avatar DanielRios549 commented on July 29, 2024

This is what I was intended to do, I thought the SVG are put inline in runtime, not in build, so I put then in static folder in order to cache them with a service worker.

But as they are generated in build time, I move them to source folder and the warning goes away, but even using static folder, it builds normally, the warning is only when in development.

from sveltekit-svg.

Related Issues (20)

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.