How to require raw static html file on webpack

I wrote a simple template

test.html

<div>raw text with content</div>

all i want to do is request a raw file unchanged

like

require('./test.html'); // should return "<div>raw text with content</div>"

I tried loading html with an extra text plugin but it does not work

var ExtractTextPlugin = require('extract-text-webpack-plugin'); 

module.exports =
{
    module:
    {
        loaders:
            [
                { test: /\.html$/, loader: 'html' }
            ]
    },
    plugins: [
        new ExtractTextPlugin("[name].html")
    ]
};
+4
source share
1 answer

Try using html-loader:

 import TestTemplate from 'html!./test.html';
+4
source

Source: https://habr.com/ru/post/1649707/


All Articles