0.0.2 • Published 10 months ago

@zzcyes/interpolate-html-plugin v0.0.2

Weekly downloads
-
License
MIT
Repository
github
Last release
10 months ago

Interpolate HTML Plugin

A webpack plugin that allows you to interpolate custom variables into index.html. This plugin is compatible with the latest versions of HtmlWebpackPlugin, supporting both getCompilationHooks and getHooks methods.

Installation

npm install interpolate-html-plugin --save-dev

Usage

In your webpack configuration:

const HtmlWebpackPlugin = require('html-webpack-plugin');
const InterpolateHtmlPlugin = require('interpolate-html-plugin');

module.exports = {
    plugins: [
            new HtmlWebpackPlugin({
                template: 'public/index.html',
            }),
            new InterpolateHtmlPlugin(HtmlWebpackPlugin, {
                'MY_VARIABLE': 'my value',
                'ANOTHER_VARIABLE': 42,
                // Add more variables as needed
            }),
        ],
};

Then, in your index.html:

<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title><%= APP_TITLE %></title>
    <meta name="description" content="<%= APP_DESCRIPTION %>" />
  </head>
  <body>
    <h1><%= APP_TITLE %></h1>   
  </body>
</html>
0.0.2

10 months ago

0.0.1

10 months ago