mini-html-extract-plugin

0.2.2 • Public • Published

mini-html-extract-plugin

Generate HTML wrapper file(s) for specific entries.

Installing

npm install --save-dev mini-html-extract-plugin

Usage

const MiniHtmlExtractPlugin = require('mini-html-extract-plugin');

...
plugins: [
  // all entries, '[name].html' found in '[output.path]'
  new MiniHtmlExtractPlugin(),

  // specific entries
  new MiniHtmlExtractPlugin({ entries: ['app', 'subapp'] }),

  // filename: '[name].[ext]?[contenthash]'
  new MiniHtmlExtractPlugin({ filename: `[name]-filename.html`, entries: ['app'] }),

  // template content with builtin placeholders: '[entryName]', '[entryJsFilename]'
  new MiniHtmlExtractPlugin({
    filename: `[name]-template.html`, entries: ['app'],
    template: '<html><body>[entryName]<div id="root"></div><script src="[entryJsFilename]"></script></body></html>'
  }),

  // template content with custom placeholders: '[xxx]', '[yyy]' ...
  new MiniHtmlExtractPlugin({
    filename: `[name]-template-placeholder.html`, entries: ['app'],
    template: '<html><body>[xxx][yyy][yyy]<div id="root"></div><script src="[entryJsFilename]"></script></body></html>',
    placeholder: { xxx: 'a', yyy: 'p' }
  }),

  // template file(absolute path) with builtin placeholders: '[entryName]', '[entryJsFilename]'
  new MiniHtmlExtractPlugin({
    filename: `[name]-templatePath.html`, entries: ['app'],
    templatePath: path.resolve(__dirname, './test/template.html')
  }),

  // template file(absolute path) with custom placeholders: '[xxx]', '[yyy]' ...
  new MiniHtmlExtractPlugin({
    filename: `[name]-templatePath-placeholder.html`, entries: ['app'],
    templatePath: path.resolve(__dirname, './test/template-placeholder.html'),
    placeholder: { xxx: 'a', yyy: 'p' }
  }),
],
...

Building

npm install
npm start
npm test

Package Sidebar

Install

npm i mini-html-extract-plugin

Weekly Downloads

11

Version

0.2.2

License

Apache-2.0

Unpacked Size

91.5 kB

Total Files

5

Last publish

Collaborators

  • luics