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

94
Views
Read a file content as a string in Vue

Some other post respond to the same problem (here, here and here) by using raw-loader but from my understanding it is deprecated for webpack v5 (but I'm not sure if it's relevant for Vue).

Also when I tried using it my file got loaded as a path : for example doing import file from '/src/assets/article.txt' creates a variable named 'file' containing the path as a String.

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

You're right raw-loader has been deprecated in Webpack 5. You should use Asset Modules instead.

Asset Modules type replaces all of these loaders by adding 4 new module types:

  • asset/source exports the source code of the asset. Previously achievable by using raw-loader.

Here is an example of the vue.config.js:

module.exports = {
  configureWebpack: {
    module: {
      rules: [
        {       
         test: /\.txt/,
         type: 'asset/source',
        }
      ]
    },
  }
}

I tested it on a vanilla Vue 3 project installed with Vue CLI. It worked perfectly.

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!