0

I have implemented html-loader on my Webpack configuration file:

module: {
    rules: [
        {
            test: /\.html$/i,
            exclude: /(node_modules)/,
            use: ['html-loader'],
        },
    ]
}

When I try to run webpack dev-server with the following line in index.js

import html from  `./app/components/auth/auth.html`;

it's return the following error: enter image description here

I have tried to log all the files which are scanned and it seems that Webpack doesn't even check the entire app directory in my src folder:

{
    test: (path) => {
        console.log(path)
        return /\.html$/i.test(path)
    },
    exclude: /(node_modules)/,
    use: ['html-loader'],
},

The only HTML file that was printed was index.html, which is located in the directory where webpack files are located.

My directory:

enter image description here

Ron Rofe
  • 738
  • 1
  • 9
  • 25
  • 2
    Don’t use backticks in your import statements. Use single quotes instead. – Terry Jul 22 '20 at 05:25
  • @Terry lol. thanks. I actually done that because I have the following question: when Im using `import()` on runtime, to fetch HTML file, It returns me a module object. instead of a string. How can I fetch it as a string? – Ron Rofe Jul 22 '20 at 05:32

0 Answers0