ivh

inject-variable-html-webpack-plugin

inject variable to the head of html by html-webpack-plugin

Showing:

Popularity

Downloads/wk

0

Maintenance

No Maintenance Data Available

Package

Dependencies

0

Size (min+gzip)

0.4KB

License

ISC

Type Definitions

Tree-Shakeable

No?

Categories

Readme

Inject Variable HTML Webpack Plugin

Extension plugin for html-webpack-plugin to inline variable by webpack. Default inlines in head tag.

Example output

Script tag to assign global webpack variable, injected in <head>.

<head>
  <script>window.variableKey={"aa":"11","bb":"22"}</script>
</head>

Usage

Install via npm/yarn

  • npm install inject-variable-html-webpack-plugin --save-dev
  • yarn add inject-variable-html-webpack-plugin --dev

webpack.config.js

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

module.exports = {
  // your config values here
  plugins: [
    new HtmlWebpackPlugin({
        template: './index-template.ejs'
    }),
    // InjectVariableHtmlWebpackPlugin defaults to:
    // { variableKey: ’variableKey‘, variableValue: {} }
    new InjectVariableHtmlWebpackPlugin()
  ]
};

Config

const inlineChunkManifestConfig = {
  variableKey: ’variableKey‘, // ’variableKey‘ is default
  variableValue: {}, // {} is default; use in html-webpack-plugin template
};

new InjectVariableHtmlWebpackPlugin(inlineChunkManifestConfig)

Rate & Review

Great Documentation0
Easy to Use0
Performant0
Highly Customizable0
Bleeding Edge0
Responsive Maintainers0
Poor Documentation0
Hard to Use0
Slow0
Buggy0
Abandoned0
Unwelcoming Community0
100