-
-
Notifications
You must be signed in to change notification settings - Fork 23
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Import from static folder #9
Comments
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 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. |
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 |
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 |
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 But as they are generated in build time, I move them to |
When import SVGs from static folder, either with relative path or using an alias, this error occurs:
files in the public directory are served at the root path. Instead of /static/icons/file.svg?import, use /icons/file.svg?import
The problem is that if I ommit the
static
folder, it says the SVG is not a valid SSR Component.The text was updated successfully, but these errors were encountered: