HTML comments

JSX comments such as {/* comment */} are not included in generated HTML. Use pluginComment() and Comment to leave section markers or notes in delivered files.

Table of Contents

Add the comment plugin

vite.config.ts
import { defineConfig, pluginSsg, pluginComment } from "minista"

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

Use Comment

src/pages/index.tsx
import { Comment } from "minista/assets"

export default function Page() {
  return (
    <>
      <Comment text="Main content starts" />
      <h1>My Site</h1>
      <Comment text="Main content ends" />
    </>
  )
}

You can use string children instead of text. The output is a regular HTML comment.

Excerpt from dist/index.html
<!-- Main content starts -->
<h1>My Site</h1>
<!-- Main content ends -->

Check comments

Open the HTML generated by npm run build and check the comment positions. Comments are not displayed on screen but can be read in the HTML source, so do not include private information.

The plugin has no options. See pluginComment for prop types.

Next, Code formatting for delivery makes output easier to read.