#What file types are supported for asset imports?

1 messages · Page 1 of 1 (latest)

broken light
#

Currently, https://remix.run/docs/en/main/file-conventions/asset-imports mentions:

Any files inside the app folder can be imported into your modules
and:
It [...] can be used for anything.
However, I just tried

import docxTemplate from './template.docx'
export default function Component() {
  return <a href={docxTemplate}>link</a>
}

and it doesn’t work. I get a TypeScript error (Cannot find module './template.docx' or its corresponding type declarations.ts(2307)), which can be fixed by creating a template.docx.d.ts file:

// template.docx.d.ts
const url: string
export default url

Apart from this, however, I get the following ESBuild error:
✘ [ERROR] No loader is configured for ".docx" files: src/routes/component/template.docx
when running either remix dev or remix build.

I’m fine with putting the file in the public folder and using a hard-coded pathname to link to the file. However, given that the docs state that this should work for any file, I’m wondering if I’m doing something wrong.

Thanks in advance for your advice!

chrome tree
#

If you wish to add support for a new file ext, please open a PR with the relevant extension and loader to that file to start a discussion.

#

I think that wording is left-over from when we had a rollup based compiler that handled all unknown exts as a file URL.