The introduction of html-webpack-plugin, nesting into html, cannot be parsed

index.html


</div>

the first layer <% = require ("htmlMurloaderloader.)% > can be introduced normally, while <% = require of systemMainTab/index.html <% = require (" htmlMaiLoader.. heading Paginationindex.html")% > cannot be parsed. Is there any method that can be nested to parse it? is there any way to parse it?

is there any method that can be nested to parse it?

one way is to introduce modules in assembly through js, but it is not well implemented in this way


now that you've used html-loader , you don't actually need to render html through the template of html-webpack-plugin . After configuring html-loader in webpack to enable interpolate, refer to it through the ES6 string template.

webpack:

{
    test: /\.html$/,
    use: [{
        loader: "html-loader",
        options: {
            interpolate: true
        }
    }]
}

html:

<!DOCTYPE html>
<html lang="en">
<head>
    ${require("./common.html")}
</head>

then in common.html, you can continue to use ${require ("xxx.html")} for references. This should be simpler to write than if you use <% =.% > .

Menu