Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

feat: Add template content #1401

Merged
merged 1 commit into from
Apr 9, 2020
Merged

feat: Add template content #1401

merged 1 commit into from
Apr 9, 2020

Conversation

jantimon
Copy link
Owner

@jantimon jantimon commented Apr 8, 2020

This templateContent features has already existed before but it was wrongly typed and not well documented.

It allows inline templates:

webpack.config.js

new HtmlWebpackPlugin({
  templateContent: `
    <html>
      <body>
        <h1>Hello World</h1>
      </body>
    </html>
  `
})

The templateContent can also access all templateParameters values.
webpack.config.js

new HtmlWebpackPlugin({
  injext: false
  templateContent: ({htmlWebpackPlugin}) => `
    <html>
      <head>
        ${htmlWebpackPlugin.tags.headTags}
      </head>
      <body>
        <h1>Hello World</h1>
        ${htmlWebpackPlugin.tags.bodyTags}
      </body>
    </html>
  `
})

⚠️ This approach does not allow to use weboack loaders for your template and will not update the template on changes

@jantimon jantimon merged commit 4740bf7 into master Apr 9, 2020
@lock lock bot locked as resolved and limited conversation to collaborators May 20, 2020
@jantimon jantimon deleted the feature/template-content branch January 3, 2021 18:47
# for free to subscribe to this conversation on GitHub. Already have an account? #.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant