nguyenbatranvan / vite-multiple-assets

npm package
https://www.npmjs.com/package/vite-multiple-assets
MIT License
12 stars 7 forks source link

allow to extend and/or have default for mime types. #6

Closed dirkbolte closed 11 months ago

dirkbolte commented 11 months ago

I have a static asset without an extension (in my case , a file called userinfo as I'm mimicing an OIDC server ). In the default implementation, this results in the following error: TypeError [ERR_HTTP_INVALID_HEADER_VALUE]: Invalid value "undefined" for header "Content-Type".

I ended up patching the package to add the file + content type I needed.

It would be great if this plugin would provide the following functionalities:

nguyenbatranvan commented 11 months ago

I have a static asset without an extension (in my case , a file called userinfo as I'm mimicing an OIDC server ). In the default implementation, this results in the following error: TypeError [ERR_HTTP_INVALID_HEADER_VALUE]: Invalid value "undefined" for header "Content-Type".

I ended up patching the package to add the file + content type I needed.

It would be great if this plugin would provide the following functionalities:

  • have a default mime type when none was found instead ofundefined+ an error when running withvite`)
  • allow to overwrite said default
  • add custom mime types
  • extend mime type check to support the actual filename and/or a glob

What a great feature suggestion!! I will add that feature to the plugin soon. Thank you very much

nguyenbatranvan commented 11 months ago

greeting the new day! I have provided version 1.2.3. You can extend the content type by adding config:

const dirAssets=["libs/assets","repo1/assets",...];
export default defineConfig({
    plugins: [
        DynamicPublicDirectory(dirAssets,{
            '.ac':'application/acc'
        })
    ]
})

I have added error handling, if the content type is not there it will be handled according to the mime-types library. You can try again, and if the problem is resolved, please help me close this issue!!

dirkbolte commented 11 months ago

thanks. Will take a bit but you will get feedback throughout the day.

dirkbolte commented 11 months ago

seems to work. Awesome!! Thanks for the quick reaction.

nguyenbatranvan commented 11 months ago

seems to work. Awesome!! Thanks for the quick reaction.

tks so much!!!