interpolate-html-plugin

interpolate custom variables into index.html

Usage no npm install needed!

<script type="module">
  import interpolateHtmlPlugin from 'https://cdn.skypack.dev/interpolate-html-plugin';
</script>

README

interpolate-html-plugin

NPM version NPM downloads Build Status donate

Extracted from create-react-app

Install

This plugin is supposed to work with html-webpack-plugin

yarn add interpolate-html-plugin --dev

Usage

module.exports = {
  plugins: [
    new InterpolateHtmlPlugin({
      'NODE_ENV': 'development'
    })
  ]
}

Then you can use %NODE_ENV% in your template html file, and you can use it with html-webpack-plugin's default template syntax (lodash.template):

<% if ('%NODE_ENV%' === 'development') { %>
do something
<% } %>

Contributing

  1. Fork it!
  2. Create your feature branch: git checkout -b my-new-feature
  3. Commit your changes: git commit -am 'Add some feature'
  4. Push to the branch: git push origin my-new-feature
  5. Submit a pull request :D

Author

interpolate-html-plugin © egoist, Released under the MIT License.
Authored and maintained by egoist with help from contributors (list).

egoistian.com · GitHub @egoist · Twitter @_egoistlily