Socket
Socket
Sign inDemoInstall

@vxna/mini-html-webpack-template

Package Overview
Dependencies
Maintainers
1
Versions
16
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@vxna/mini-html-webpack-template

Minimum viable template for mini-html-webpack-plugin


Version published
Weekly downloads
49K
decreased by-6.98%
Maintainers
1
Weekly downloads
 
Created
Source

@vxna/mini-html-webpack-template

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',
        container: 'root',
        trimWhitespace: true
      },
      template: require('@vxna/mini-html-webpack-template')
    })
  ]
}

Common options

NameTypeDefaultDescription
lang{String}undefinedSet document language
title{String}'sample-app'Set document title
container{String}undefinedSet application mount point
trimWhitespace{Boolean}undefinedSafe 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'
            },
            {
              property: 'og:description',
              content: 'mini-html-webpack-template'
            }
          ],
          links: [
            {
              rel: 'shortcut icon',
              href: 'https://assets-cdn.github.com/favicon.ico',
              type: 'image/x-icon'
            }
          ]
        },
        body: {
          raw: '<div id="root"></div>'
        }
      },
      template: require('@vxna/mini-html-webpack-template')
    })
  ]
}

Extended options

NameTypeDefaultDescription
head.meta{Array}undefinedArray of objects with key + value pairs
head.links{Array}undefinedArray of objects with key + value pairs
head.scripts{Array}undefinedArray of objects with key + value pairs
head.raw{Array|String}undefinedRaw document markup
body.scripts{Array}undefinedArray of objects with key + value pairs
body.raw{Array|String}undefinedRaw document markup

Extended 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: 'extended-minification'
      },
      template: ctx =>
        minify(require('@vxna/mini-html-webpack-template')(ctx), {
          collapseWhitespace: true,
          minifyCSS: true,
          minifyJS: true
        })
    })
  ]
}

Inspired by

html-webpack-template

License

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

FAQs

Package last updated on 15 Mar 2018

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc