-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Using a html loader: raw-loader vs asset/source does not give the same output #1707
Comments
The html-webpack-plugin allows to use any loader - however if no loader is configured it provides a default loader.. This allows using an ejs like syntax without configuration. E.g.: The problem you describe could be caused by the fact that the current fallback loader is not capable of detecting asset/source.. The code for that part is here: https://github.com/jantimon/html-webpack-plugin/blob/main/lib/loader.js There are two possible solutions:
|
Same problem here for .master files (ASP.Net Framework).
Of course this also wont work
Raw-loader are deprecated in 5 so i never try it |
I ran into this issue as well, as I'm upgrading from webpack 3 to webpack 5 and am switching from html-loader to asset/source for HTML files. The issue comes from asset/source not being visible in the list of loaders, so when HTMLWebpackPlugin introspects the loader list, it can't find one. I was able to trick HTMLWebpackPlugin with a one-line passthrough loader: html-hack.js module.exports = (source) => source; webpack.config.js module.exports = {
// ...
plugins: [
new (require("html-webpack-plugin")(),
],
module: {
rules: [
{ test: /src\/index.html/, use: [require.resolve('./html-hack')],
{ test: /.html/, type: 'asset/source' },
],
}
}; I see two solutions:
The first option seems the most plausible in the short term, as it's hard to say how difficult the second would be to implement. |
Should resolve the issue |
I could not get it working.. do you have any stackblitz with solution? I trying to leave raw-loader as of angular v16, but need html to be imported as raw for achieving template concatenation .. It works on angular v15) |
Here below is my html loading snippet:
Component:
|
@PureIso tks for the info. However it didnt worked for my scenario. Could you please take a look here, at the issue and stackblitz. angular/angular#51805 (comment) how to accomplish that? tks |
Current behaviour 💣
Using
html-webpack-plugin
with a loader for html does not give the same output if I use the loaderraw-loader
or the typeasset/source
.With the
raw-loader
, I have a classic index.html corresponding to the template I provide. However, if I use theasset/source
, I have this kind of output in my index.html: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
The text was updated successfully, but these errors were encountered: