nitrojs / nitrojs/nitro

feature: Add an utility to add assets to routes

Open
#2,492 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

enhancement nuxt v2
Dominant language
TypeScript
Stars
11.2k
Forks
899
Avg merge
2d 24m
Merged PRs (30d)
40

Description

Describe the feature

Currently we can add public assets directories but not individual files which seems straight forward to add improving DX along the way.

My suggestion is creating a addPublicAsset(pathToAFile), would be interesting to support public asset hashing at build time too:

  • If I do a fetch in my application for /something/publicAsset.png it coud be doable to replace this string in build time with an hashing file like /something/32eqedqdqw.publicAsset.png but I really could be seeing it wrongly here!

Use case:

  • I need a way to add public assets without creating a temporary dir each time and hashing it based on the content.
  • I am creating a way to dynamically import tailwind css file in nuxt/tailwind module and need a pratical way to add the new asset in a nuxt module and hash it if possible.
Additional information
  • Would you be willing to help implement this feature?

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Begin by locating the existing public-assets directory handling and the route/build entry points that register those assets. Compare the current behavior with the proposed addPublicAsset(pathToAFile) API and determine how optional build-time hashing should be covered by tests. Done means individual assets can be added without a temporary directory, with the agreed hashing behavior documented and verified.

Written by the indexing model from the issue text.

Assessment

Tech stack
tailwindcss, typescript
Domain
api, backend, build-system
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
38/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.