raw-loader icon indicating copy to clipboard operation
raw-loader copied to clipboard

raw-loader returns export string instead of file content

Open FelixSab opened this issue 4 years ago • 1 comments

  • Operating System: Ubuntu:16.04
  • Node Version: 14.15.5
  • Yarn Version: 1.22.5
  • webpack Version: 5.24.0
  • raw-loader Version: ^4.0.2

Expected Behavior

Content of the file should be imported

Actual Behavior

a string like export default __webpack_public_path__ + "$test.10d9aaad.txt"; is imported

Code


import test from './test.txt';

console.log({ test }); // should return 'hello, world' but returns mentioned above string

How Do We Reproduce?

I will add that later, when I have successfully reproduced the issue on a small repo

edit: https://github.com/FelixSab/raw-loader-issue

install the npm packages and execute yarn start / npm run start. The result is shown in the console

FelixSab avatar Feb 23 '21 18:02 FelixSab

It means you use file-loader instead raw-loader for this file, anyway file-loader/url-loader/raw-loader is deprecated for webpack v5, please migrate on https://webpack.js.org/guides/asset-modules/

alexander-akait avatar Feb 24 '21 11:02 alexander-akait