@forgleaner/webpack-html-inject-plugin

1.0.0 • Public • Published

webpack-html-inject-plugin

build commitizen download npm semantic

A webpack plugin that inject some variables to entry html.

Usage

First, install webpack-html-inject-plugin as a development dependency:

npm i -D @forgleaner/webpack-html-inject-plugin

Then, add it to your webpack.config.js:

const HtmlInjectPlugin = require('webpack-html-inject-plugin');

webpackOptions.plugins.push(new HtmlInjectPlugin({
  filename: 'index.html',
  data: {
           ENV_DEBUG: false,
           ENV_DEV: true,
           token: 'zawQrZL963RGtXrd2rYmLmUOeckesAaLlYgtNVA89'
  }
}));

Before

<script>
  window.token = {{token}};
  window.ENV_DEBUG = {{ENV_DEBUG}};
  window.ENV_DEV = {{ENV_DEV}};
</script>

After

<script>
  window.ENV_DEBUG = false;
  window.ENV_DEV = true;
  window.token = 'zawQrZL963RGtXrd2rYmLmUOeckesAaLlYgtNVA89';
</script>

API

new HtmlInjectPlugin([options])

options

Type: object

filename

Type: String

The file to write the HTML to.
data

Type: object

Declara some variables to html.

Package Sidebar

Install

npm i @forgleaner/webpack-html-inject-plugin

Weekly Downloads

0

Version

1.0.0

License

MIT

Unpacked Size

5.76 kB

Total Files

3

Last publish

Collaborators

  • forgleaner