qrac / minista

Static site generator with 100% static export from React and Vite.
https://minista.qranoko.jp
167 stars 13 forks source link

Couldn't minify HTML & other outputs #116

Closed ken0x0a closed 1 year ago

ken0x0a commented 1 year ago

I tried to minify HTML, but doesn't work.

Is there a way to do that?

My minista.config.ts is following.

import { defineConfig } from "minista"

export default defineConfig({
  // ...
  vite: {
    server: {
      port: process.env.PORT || 3000, // number
    },
    build: {
      minify: true,
    },
    esbuild: {
      minify: true,
      minifySyntax: true,
    },
  },
  // ...
  beautify: {
    useHtml: false, // boolean
    useAssets: false, // boolean
    // ...
  },
})
qrac commented 1 year ago

@ken0x0a Thank you for your question!

However, I'm sorry, but the current minista (v2 and v3-alpha) does not have an HTML minify function.

This is because we expect the client to edit the HTML after delivery, and we want to focus on formatting rather than minify.

We may implement a minify function for HTML in the future, but it will be difficult in the short term, so how about adding post-processing with an npm script?

$ npm i -D html-minifier-terser
{
   "scripts": {
     "minify-html": "html-minifier-terser --input-dir ./dist --output-dir ./dist --file-ext html --collapse-whitespace"
   },
}
ken0x0a commented 1 year ago

@qrac Thank you for your response!

That's simple! Great! Thank you!