peerigon / extract-loader

webpack loader to extract HTML and CSS from the bundle
The Unlicense
317 stars 74 forks source link

Generating "[object Object]" for placeholders... #96

Open isaacl opened 3 years ago

isaacl commented 3 years ago

I'm hitting a weird bug w/ html-loader, possibly related to webpack 5? Any ideas/suggestions?

Thanks! -Isaac

Test repo

<!DOCTYPE html>
<html>
  <head>
    <link rel="stylesheet" type="text/css" href="./index.scss" />
  </head>
  <body>
    <script src="./index.js" />
    Hio
  </body>
</html>

output:

<!DOCTYPE html>
<html>
  <head>
    <link rel="stylesheet" type="text/css" href="[object Object]" />
  </head>
  <body>
    <script src="[object Object]" />
    Hio
  </body>
</html>
terox commented 3 years ago

Hello!

I am experimenting the same issue in this repo.

Related: https://github.com/webpack-contrib/html-loader/issues/329

isaacl commented 3 years ago

@terox I had two issues in my package. 1) extract-loader does NOT handle script src properly. Solution: use absolute links to make html-loader ignore them, or turn them off in html-loader options 2) You cannot combine extract-loader with minicssplugin.

Here's my current config, which works. https://gist.github.com/isaacl/64f689595ad5fb959b0565cc50514ae2

I also wrote this hacky script to fix the script tag manually post-build: https://gist.github.com/isaacl/7f8f3855c151f7fb21d8213b9cbde1ac

terox commented 3 years ago

@isaacl I updated my master branch with a couple of useful PR from the main project that fix this issue and alises: https://github.com/terox/extract-loader

isaacl commented 3 years ago

@terox This project just wasn't maintained well enough for me. So I moved on to rollup, which had better support, and then I moved again to vite, which I think has the best current tooling and support.