@vxna/mini-html-webpack-template

WebJar for @vxna/mini-html-webpack-template

License

License

MIT
GroupId

GroupId

org.webjars.npm
ArtifactId

ArtifactId

vxna__mini-html-webpack-template
Last Version

Last Version

0.1.7
Release Date

Release Date

Type

Type

jar
Description

Description

@vxna/mini-html-webpack-template
WebJar for @vxna/mini-html-webpack-template
Project URL

Project URL

http://webjars.org
Source Code Management

Source Code Management

https://github.com/vxna/mini-html-webpack-template

Download vxna__mini-html-webpack-template

How to add to project

<!-- https://jarcasting.com/artifacts/org.webjars.npm/vxna__mini-html-webpack-template/ -->
<dependency>
    <groupId>org.webjars.npm</groupId>
    <artifactId>vxna__mini-html-webpack-template</artifactId>
    <version>0.1.7</version>
</dependency>
// https://jarcasting.com/artifacts/org.webjars.npm/vxna__mini-html-webpack-template/
implementation 'org.webjars.npm:vxna__mini-html-webpack-template:0.1.7'
// https://jarcasting.com/artifacts/org.webjars.npm/vxna__mini-html-webpack-template/
implementation ("org.webjars.npm:vxna__mini-html-webpack-template:0.1.7")
'org.webjars.npm:vxna__mini-html-webpack-template:jar:0.1.7'
<dependency org="org.webjars.npm" name="vxna__mini-html-webpack-template" rev="0.1.7">
  <artifact name="vxna__mini-html-webpack-template" type="jar" />
</dependency>
@Grapes(
@Grab(group='org.webjars.npm', module='vxna__mini-html-webpack-template', version='0.1.7')
)
libraryDependencies += "org.webjars.npm" % "vxna__mini-html-webpack-template" % "0.1.7"
[org.webjars.npm/vxna__mini-html-webpack-template "0.1.7"]

Dependencies

compile (1)

Group / Artifact Type Version
org.webjars.npm : common-tags jar [1.7.2,2)

Project Modules

There are no modules declared in this project.

@vxna/mini-html-webpack-template

Build Status npm

Template for mini-html-webpack-plugin that extends default features with useful subset of options

Warning

It does not work with html-webpack-plugin

Common usage

webpack.config.js

const MiniHtmlWebpackPlugin = require('mini-html-webpack-plugin')

module.exports = {
  plugins: [
    new MiniHtmlWebpackPlugin({
      context: {
        title: 'common-usage',
        favicon: 'https://assets-cdn.github.com/favicon.ico',
        container: 'root',
        trimWhitespace: true,
      },
      template: require('@vxna/mini-html-webpack-template'),
    }),
  ],
}

Common options

Name Type Default Description
lang {String} undefined Set document language
title {String} 'sample-app' Set document title
favicon {String} undefined Set document favicon
container {String} undefined Set application mount point
trimWhitespace {Boolean} undefined Safe document whitespace reduction

Extended usage

webpack.config.js

const MiniHtmlWebpackPlugin = require('mini-html-webpack-plugin')

module.exports = {
  plugins: [
    new MiniHtmlWebpackPlugin({
      context: {
        title: 'extended-usage',
        head: {
          meta: [
            {
              name: 'description',
              content: 'mini-html-webpack-template',
            },
          ],
        },
        body: {
          raw: '<div id="root"></div>',
        },
        attrs: {
          js: {
            async: '',
            type: 'text/javascript',
          },
        },
      },
      template: require('@vxna/mini-html-webpack-template'),
    }),
  ],
}

Extended options

Name Type Default Description
head.meta {Array} undefined Array of objects with key + value pairs
head.links {Array} undefined Array of objects with key + value pairs
head.scripts {Array} undefined Array of objects with key + value pairs
head.raw {Array|String} undefined Generates raw document markup
body.scripts {Array} undefined Array of objects with key + value pairs
body.raw {Array|String} undefined Generates raw document markup
attrs.js {Object} undefined Applies html attributes to webpack output
attrs.css {Object} undefined Applies html attributes to webpack output

Advanced minification

For custom needs html-minifier middleware and all of it's options could be used

webpack.config.js

const { minify } = require('html-minifier')
const MiniHtmlWebpackPlugin = require('mini-html-webpack-plugin')

module.exports = {
  plugins: [
    new MiniHtmlWebpackPlugin({
      context: {
        title: 'advanced-minification',
      },
      template: (ctx) =>
        minify(require('@vxna/mini-html-webpack-template')(ctx), {
          collapseWhitespace: true,
          minifyCSS: true,
          minifyJS: true,
        }),
    }),
  ],
}

Complex security features

SRI is out of scope of this project and it's recommended to use html-webpack-plugin with it's ecosystem tools.

Inspired by

html-webpack-template

License

MIT (http://www.opensource.org/licenses/mit-license.php)

Versions

Version
0.1.7