Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to require raw static html file on webpack

I have written a simple template

test.html

<div>raw text with content</div>

all I want to do is requiring the raw file, with no modifications

like

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

I have tried loading the html using the extra-text-plugin, but it doesn't work

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

module.exports =
{
    module:
    {
        loaders:
            [
                { test: /\.html$/, loader: 'html' }
            ]
    },
    plugins: [
        new ExtractTextPlugin("[name].html")
    ]
};
like image 546
user3531149 Avatar asked Jul 31 '16 18:07

user3531149


1 Answers

Try to use html-loader:

 import TestTemplate from 'html!./test.html';
like image 167
stdob-- Avatar answered Oct 06 '22 10:10

stdob--