Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

193
Views
Base64 of webpack inline font

I need to get the font that is in ./src/assets/fonts and convert it to base64

my config-overrides.js

    addWebpackModuleRule({
    test: /\.ttf$/,
    use: [
        {
            loader: 'ttf-loader',
            options: {
                name: './src/assets/fonts/[hash].[ext]'
            }
        }
    ]
}),

and the file itself, in which I import this font, where I already convert it to base64

import font from '../assets/fonts/font.ttf'

const someFun = () =>{
    return btoa(font);
}

But I am getting error

Module parse failed: Unexpected token (4:7)
File was processed with these loaders:
* ./node_modules/ttf-loader/src/index.js
You may need an additional loader to handle the result of these loaders.
| 
| module.exports = createFontFamily({
>   ttf: export default __webpack_public_path__ + 
"./src/assets/fonts/7233a7aee250f9b77fba5f735143ad39.ttf",
|   woff: export default __webpack_public_path__ + 
"./src/assets/fonts/f46b66ed2d54e5321411edfe916b7300.woff",
|  });
 
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

Okay, I changed the loader to this

 loader: 'base64-inline-loader'

and now everything works. It will automatically convert the file to base64

about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!