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

provide option to copy along static files #63

Open
tobiasdiez opened this issue Nov 11, 2022 · 5 comments
Open

provide option to copy along static files #63

tobiasdiez opened this issue Nov 11, 2022 · 5 comments

Comments

@tobiasdiez
Copy link
Contributor

Sometimes you want to copy static files (in my case a ts file that servers as the source for addTemplate). This currently doesn't seem to be possible.

@pi0
Copy link
Member

pi0 commented Nov 14, 2022

Does it works if you put it inside src/runtime/static?

@harlan-zw
Copy link
Collaborator

Doing this worked for me

nuxt.hooks.hook('nitro:config', (nitroConfig) => {
  nitroConfig.publicAssets = nitroConfig.publicAssets || []
  nitroConfig.publicAssets.push({ dir: resolve('./runtime/public'), maxAge: 31536000 })
})

@pi0
Copy link
Member

pi0 commented Jan 17, 2023

@harlan-zw Nice. That would be a nice kit utility candidate.

@IlyaSemenov
Copy link

@pi0:

Does it works if you put it inside src/runtime/static?

Not really. template.ts is copied but it's transformed into the pair of .mjs and .d.ts which is not desireable (in particular, that means addTemplate calls should be different between dev and production).

One could work around that by using non-ts extension (such as .ts.template) but then:

  • The file is not recognized by IDE (unless manually fiddled).
  • addTemplate needs explicit dst, otherwise it keeps the .template extension. But explicit dst means the filename.[hash].ts mechanism is not used.

All and all, that's not really an option. We need a way to copy over certain files verbatim.

Suggestions:

  • Treat .template.ts as an exception for transformation.
  • Copy the entire src/assets into dist/assets (then it's up to the developer how to use it).

@pi0
Copy link
Member

pi0 commented May 24, 2023

I think you still can use a top level directory and include it in package.json files without transforms (dist and src having same relative path) but sure supporting an assets type could be nice option.

Upstream: unjs/unbuild#266

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants