New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details
Socket
Book a DemoSign in
Socket

html-webpack-format-plugin

Package Overview
Dependencies
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

html-webpack-format-plugin

格式化由underscore-template-loader等模板系统生成的html代码,让html-webpack-plugin输出的Html文件更加美观

latest
Source
npmnpm
Version
1.0.0
Version published
Maintainers
1
Created
Source

Format output html extension for the HTML Webpack Plugin

将 HTML Webpack Plugin 输出的 html 文件格式化 参考: rehypejs/rehype-format 对格式逻辑做了些修改

Basic Usage

在 Webpack 中使用

var HtmlWebpackFormatPlugin = require('html-webpack-format-plugin')

添加到插件列表

plugins: [new HtmlWebpackPlugin(), new HtmlWebpackFormatPlugin()]

HtmlWebpackPlugin 之前输出的文件

<!DOCTYPE html>
<html>
  <head>
    <title>Hello!</title>
    <meta charset="utf8" />
  </head>
  <body>
    <!-- body/section.html -->
    <section><p>hi there</p></section>
  </body>
</html>

使用此插件之后输出的 html 文件

<!DOCTYPE html>
<html>
  <head>
    <title>Hello!</title>
    <meta charset="utf8" />
  </head>
  <body>
    <!-- body/section.html -->
    <section>
      <p>hi there</p>
    </section>
  </body>
</html>

API

HtmlWebpackFormatPlugin(options)

Format white-space in the processed tree.

  • Collapse all white-space (to a single space or newline)
  • Remove unneeded white-space
  • Inject needed newlines and indentation
  • Indent previously collapsed newlines properly

All superfluous white-space is removed. However, as newlines are kept (and later properly indented), your code will still line-wrap as expected.

options
options.indent

number, string, default: 2 — Indentation per level. When number, uses that amount of spaces. When string, uses that per indentation level.

options.indentInitial

boolean, default: true — Whether to indent the first level (usually, in the html element, thus not indenting head and body).

options.blanks

Array.<string>, default: [] — List of tag-names, which, when next to each other, are joined by a blank line (\n\n). For example, when ['head', 'body'] is given, a blank line is added between these two.

License

MIT

Keywords

webpack

FAQs

Package last updated on 30 Mar 2019

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