html-webpack-template-literal-plugin
💝 Use es6 template literal to compile html file that works with html-webpack-plugin(support webpack v4)
install
npm install html-webpack-template-literal-plugin --save-dev
or
yarn add html-webpack-template-literal-plugin -D
usage
- specify
templateData
option inhtml-webpack-plugin
- use
html-webpack-template-literal-plugin
the following values are available besides the values in templateData
publicPath: 'String, webpack publicPath' assets: 'Array, all assets files name generated by webpack' webpack: 'Object, the webpack stats object(it is not the final stats)' webpackConfig: 'Object, webpack config object' pluginAssets: 'Object, assets info generated by html-webpack-plugin'
example
webpack.config.js
const HtmlWebpackPlugin = ;const HtmlWebpackTemplateLiteralPlugin = ; const webpackConfig = // ... plugins: inject: true template: '!!html-loader!index.html' // other config options templateData: // template literal data title: 'this is title'
index.html
${title}
⚠️ NOTE
you must set a loader to process index.html
eg: html-loader
or raw-loader
are both ok.
please view https://github.com/jantimon/html-webpack-plugin/blob/master/docs/template-option.md for detail.
license
MIT