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

how to setup loader - No loader is configured for ".ttf" #459

Closed
tgmarinho opened this issue Nov 20, 2021 · 7 comments
Closed

how to setup loader - No loader is configured for ".ttf" #459

tgmarinho opened this issue Nov 20, 2021 · 7 comments
Labels

Comments

@tgmarinho
Copy link

hi, how can I setup loaders to other files like .ttf using tsup?

 ✘ tgmarinho@DESKTOP-EOOV6G8  ~/Developer/crow/crow-sdk   develop ±  yarn dev
yarn run v1.22.5
$ tsup --watch
 CLI  Building entry: src/index.ts
 CLI  Using tsconfig: /home/tgmarinho/Developer/crow/crow-sdk/tsconfig.json
 CLI  tsup v5.6.0
 CLI  Using tsup config: /home/tgmarinho/Developer/crow/crow-sdk/tsup.config.ts
 CLI  Running in watch mode
 CLI  Target: node12
 CLI  Cleaning output folder
 CJS  Build start
 > src/components/globalStyle.ts:1:19: error: No loader is configured for ".ttf" files: src/components/fonts/Comforter.ttf
    1 │ import sfWoff from './fonts/Comforter.ttf'
@egoist egoist closed this as completed in 85cfd15 Nov 20, 2021
@github-actions
Copy link

🎉 This issue has been resolved in version 5.7.4 🎉

The release is available on:

Your semantic-release bot 📦🚀

@egoist
Copy link
Owner

egoist commented Nov 20, 2021

Now I added some default loaders:

        '.aac': 'file',
        '.css': 'file',
        '.eot': 'file',
        '.flac': 'file',
        '.gif': 'file',
        '.jpeg': 'file',
        '.jpg': 'file',
        '.mp3': 'file',
        '.mp4': 'file',
        '.ogg': 'file',
        '.otf': 'file',
        '.png': 'file',
        '.svg': 'file',
        '.ttf': 'file',
        '.wav': 'file',
        '.webm': 'file',
        '.webp': 'file',
        '.woff': 'file',
        '.woff2': 'file',

You can also change it: https://tsup.egoist.sh/#custom-loader

@tgmarinho
Copy link
Author

Thank you very much Kevin! I'll try it 👍🙏🎉🥳🚀❤️

@tgmarinho
Copy link
Author

tgmarinho commented Nov 21, 2021

Heads up:

Who's using tsup in some project:

add the interface:

fonts.d.ts:

declare module '*.ttf'

Then you can import files *.ttf like:

import fontInter from './fonts/Inter-Regular.ttf'

export const globalCrowStyles = {
  '@font-face': {
    fontFamily: `'Inter', sans-serif`,
    src: `url(${fontInter}) format("truetype")`,
    fontDisplay: 'swap',
    fontWeight: 'normal',
  },
`` 

@ScreamZ
Copy link

ScreamZ commented Mar 2, 2022

@egoist The issue is that it doesn't add the dist to the path for files.

I have to do the following but not sure if best way :

const FontsMap: Record<string, string> = {
  "Branding-Bold": path.resolve("dist", require("./Branding-Bold.ttf")),
};

@tgmarinho any idea too ?

@tgmarinho
Copy link
Author

@ScreamZ I end up using google fonts. I didn't faced this issue.

@ralyodio
Copy link

has anyone found a fix?

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

No branches or pull requests

4 participants