Coder Social home page Coder Social logo

hu-template-minifier's Introduction

Hu-Template-Minifier

该类库将使用了 模板字符串 - 标签 ( Template literals ) 功能实现模板定义的类库中的 HTML 代码进行压缩.



Overview

html`
  <div title=${ 'title' } class="a ${ b } c ${ d }">
    <div>...</div>
    ${
      html`
        <div>
          <span>Something ...</span>
        </div>
      `
    }
    <div>...</div>
  </div>
`

// ↓↓↓

html`<div title=${ 'title' } class="a ${ b } c ${ d }"> <div>...</div> ${
      html`<div> <span>Something ...</span> </div>`
    } <div>...</div> </div>`

Installation

npm install @moomfe/hu-template-minifier

Usage

// 使用 minifier 的 rollup 插件
const minifier = require('@moomfe/hu-template-minifier/rollup');

rollup({
  plugins: [
    minifier(/* options */)
  ]
});

Plugin Options

{
  // 需要进行压缩的文件后缀
  extensions: [ '.js' ], // 默认值
      // 可包含多个
      extensions: [ '.js', '.ts' ],

  // 需要包含的文件
  include: undefined, // 默认值 ( 包含全部 )
      // 普通匹配
      include: 'index.js',
      // 使用 minimatch 格式进行匹配
      include: 'components/*/index.js',
      include: 'components/**/index.js',
      // 使用正则进行匹配
      include: /api\.js/,
      // 使用支持的格式组成数组进行匹配
      include: [
        'components/*/index.js',
        /api\.js/
      ],

  // 需要从已包含的文件中排除的文件
  // 使用的格式与 include 选项一致, 不再进行举例
  exclude: undefined, // 默认值

  // 保留一个空格
  conservativeCollapse: true,

  // 移除注释
  removeComments: false
}

Supports

Transplant From

License

Hu-Template-Minifier is licensed under a MIT License.

hu-template-minifier's People

Contributors

zhang-wei-666 avatar

Stargazers

 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.