Skip to content

Using a html loader: raw-loader vs asset/source does not give the same output #1707

@PierBJX

Description

@PierBJX

Current behaviour 💣

Using html-webpack-plugin with a loader for html does not give the same output if I use the loader raw-loader or the type asset/source.

With the raw-loader, I have a classic index.html corresponding to the template I provide. However, if I use the asset/source, I have this kind of output in my index.html:

var _ = non_webpack_require("C:\Users...\node_modules\lodash\lodash.js");module.exports = function (templateParams) { with(templateParams) {return (function(data) { var __t, __p = ''; __p += '<!doctype html>Webpack App'; return __p })();}}

A discussion has been already opened on webpack github and the problem is with html-webpack-plugin. Find the discussion here.

Expected behaviour ☀️

We should have the same output as it is mentioned in the documentation.

Reproduction Example 👾

You can find this repo which reproduces the issue. Just switch between the raw-loader and the asset/source.

Environment 🖥

Node.js v14.17.5
win32 10.0.18363
html-webpack-plugin 5.5.0
webpack version 5.64.4

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions