Skip to content
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

Retrieve static assets from a sveltekit package/library #3559

Closed
LeviticusNelson opened this issue Jan 31, 2023 · 3 comments · May be fixed by X-oss-byte/turbo#157, X-oss-byte/turbo#170, X-oss-byte/turbo#172 or X-oss-byte/turbo#195

Comments

@LeviticusNelson
Copy link

Which project is this feature idea for?

Turborepo

Describe the feature you'd like to request

You can retrieve assets from local static directory in sveltekit using:
<link rel="stylesheet" href="%sveltekit.assets%/assets/css/custom.css" />
But I want to send all of my static assets into a sveltekit package so that I can reuse custom components and also not have multiple copies of the static assets in each workspace.

Describe the solution you'd like

Similar import like:
<link rel="stylesheet" href="%@package_name:sveltekit.assets%/assets/css/custom.css" />

Describe alternatives you've considered

Right now I have multiple copies of my assets in each workspace.

@mehulkar
Copy link
Contributor

@LeviticusNelson can you clarify what this issue is about? Are you asking for a feature in Sveltekit? Or is this perhaps for turbo_pack_ ? The issue says Turborepo, so I want to make sure before proceeding.

@LeviticusNelson
Copy link
Author

@mehulkar hi, I figured out how to import static assets from a different directory in svelte.config.js:

const config = {
    preprocess: [preprocess()],

    kit: {
        adapter: adapter(),
        files: {
            assets: "../../packages/ui/static",
        },
    },
};

I am now not sure if this would relate more to sveltekit or turbo because I would like to do something like this for future apps/packages in my monorepo:

 const config = {
    preprocess: [preprocess()],

    kit: {
        adapter: adapter(),
        files: {
            assets: "ui/static",
        },
    },
};

@mehulkar
Copy link
Contributor

I see. It seems like you are wanting to reference another directory while bundling sveltekit? I don't think this is something turborepo can help with. Your solution to use relative paths seems workable. Alternatively, you may want to see if your package manager (npm/yarn/pnpm) may have any conveniences to resolve the name ui to a path.

cc @anthonyshew in case you have any other suggestions!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment