Skip to content
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

[Bug]: html template does not work as expected #6454

Closed
zackarychapple opened this issue May 6, 2024 · 1 comment
Closed

[Bug]: html template does not work as expected #6454

zackarychapple opened this issue May 6, 2024 · 1 comment
Labels
bug Something isn't working pending triage The issue/PR is currently untouched.

Comments

@zackarychapple
Copy link
Collaborator

System Info

zchapple@macos % npx envinfo --system --npmPackages '@rspack/*' --binaries --browser

  System:
    OS: macOS 14.4.1
    CPU: (10) arm64 Apple M1 Max
    Memory: 187.50 MB / 64.00 GB
    Shell: 5.9 - /bin/zsh
  Binaries:
    Node: 20.12.2 - ~/.nvm/versions/node/v20.12.2/bin/node
    npm: 6.14.13 - ~/.nvm/versions/node/v20.12.2/bin/npm
  npmPackages:
    @rspack/cli: ^0.6.3-canary-9bd4169-20240506141944 => 0.6.3 
    @rspack/core: ^0.6.3-canary-9bd4169-20240506141944 => 0.6.3 

Details

Using the bundled Rspack html plugin with a custom template script tags cannot be injected.

Rspack config

      new rspack.HtmlRspackPlugin({
        inject: false,
        chunks: ['main', 'vendor'],
        template: 'web-config/rspack.green.template.html',
      }),

Html template

<%= htmlWebpackPlugin.tags.headTags %>

Error Message

  ERROR in × HTML parsing error: Invalid first character of tag name
      ╭─[90:1]
   90 │ 
   91 │ <!--These are the script tags directly from the webpack build-->
   92 │ <%= htmlWebpackPlugin.tags.headTags %>
      ·  ─
   93 │ <!--End of script tags directly from webpack build-->
   94 │ 
      ╰────

Reproduce link

No response

Reproduce Steps

create a html template and try to use it.

@zackarychapple zackarychapple added bug Something isn't working pending triage The issue/PR is currently untouched. labels May 6, 2024
@chenjiahan
Copy link
Member

The features of rspack.HtmlRspackPlugin are a subset of html-webpack-plugin.

rspack.HtmlRspackPlugin does not inject the htmlWebpackPlugin.tags.headTags variable to template, if your current project depend on this, you can use html-webpack-plugin instead.

See https://www.rspack.dev/plugins/rspack/html-rspack-plugin for details.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working pending triage The issue/PR is currently untouched.
Projects
None yet
Development

No branches or pull requests

2 participants