简体   繁体   中英

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")
    ]
};

尝试使用html-loader

 import TestTemplate from 'html!./test.html';

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM