简体   繁体   English

如何在webpack上要求原始的静态html文件

[英]How to require raw static html file on webpack

I have written a simple template 我写了一个简单的模板

test.html 的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 我已经尝试使用extra-text-plugin加载html,但它不起作用

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';

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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