Skip to content

muryp/vite-plug-html

Repository files navigation

HTML & CSS minify on template literal

Install

pnpm add -D @muryp/vite-html

configs

types

// src/index.d.ts
declare global {
  function html(
    e: TemplateStringsArray,
    ...a: Array<string | number | (string | number)[]>
  ): string
  type Targs = {
    name?: string
    type?: string
  }
}
export {}

or add in src/type.d.ts

import '@muryp/vite-html/type'

or

/// <reference types='@muryp/vite-html/type'/>

vite

// vite.config.js
import { defineConfig } from 'vite'
import htmlPlug from '@muryp/vite-html/vite'

export default defineConfig({
  plugins: [htmlPlug()],
})

opts

const defaultOptsHtml: Options = {
  minifyJS: true,
  minifyCSS: true,
  minifyURLs: true,
  removeComments: true,
  collapseWhitespace: true,
}
const defaultOptsCss: cleanCss.Options = {
  returnPromise: false
}
type ArgsMurypJsLiteral = {
  include?: RegExp // default /.*\/src\/.*\.(ts|astro|js)$/
  exclude?: RegExp // default undefined
  minify?: {
    html?: boolean // default true
    css?: boolean // default true
  }
  configs?: {
    html?: Options // default => defaultOptsHtml
    css?: OptionsOutput // default => defaultOptsCss
}
  • see more option for html minifier here
  • see more option for css minifier here

Astro

// astro.config.js
import { defineConfig } from 'astro/config'
import murypAstroMinify from '@muryp/vite-html/astro'

export default defineConfig({
  integrations: [murypAstroMinify()],
})

About

vite plugin for html literal and minify.

Resources

License

Stars

Watchers

Forks

Packages

No packages published