npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

mssgen

v2.0.9

Published

Minimal static site generator with recursive root-based build

Readme

mssgen

mssgen は、HTML をそのまま書きながら静的サイトを組み立てられる、シンプルな npm 製 CLI ツールです。

  • npm install mssgen で使い始められる
  • npx mssgen / npx mssgen dev ですぐ試せる
  • common/ に共通パーツを置いて {{header.html}} のように読み込める
  • {{{ name: キー;内容 }}} で名前付きブロックを定義し、{{{{ key }}}} で別ファイルから再利用できる
  • setting.json の値を {SITE_NAME} のようなプレースホルダーへ差し込める
  • png / jpg / jpegwebp に変換し、ローカル参照も自動で .webp に更新できる

インストール

いちばん手軽な使い方

プロジェクトに追加して、npx で実行します。

npm install mssgen
npx mssgen init
npx mssgen dev

ビルドだけしたいときは次を実行します。

npx mssgen

グローバルに入れる場合

普段から CLI として使いたい場合はグローバルインストールもできます。

npm install -g mssgen
mssgen init
mssgen dev

最短スタート

1. サイト用ディレクトリを作る

新規ディレクトリでも、既存の HTML プロジェクトでも使えます。

mkdir my-site
cd my-site
npm init -y
npm install mssgen
npx mssgen init

mssgen init は、不足している次のファイルだけを作成します。

  • setting.json
  • common/header.html
  • common/footer.html
  • index.html

2. 開発サーバーを起動する

npx mssgen dev
  • デフォルトでは http://127.0.0.1:3000 で起動します
  • ファイル変更を監視し、再ビルド後にブラウザを自動リロードします
  • ポートは環境変数 MSSGEN_PORT で変更できます

例:

MSSGEN_PORT=4000 npx mssgen dev

3. 本番用にビルドする

npx mssgen

ビルド結果は dist/ に出力されます。

書き方

setting.json

{
  "variables": {
    "SITE_NAME": "My Site",
    "SITE_DESCRIPTION": "Generated by mssgen"
  },
  "build": {
    "webpExclude": ["assets/no-convert.png"]
  }
}

common/header.html

<header>
  <h1>{SITE_NAME}</h1>
  <p>{SITE_DESCRIPTION}</p>
</header>

index.html

<!DOCTYPE html>
<html lang="ja">
  <body>
    {{header.html}}
    <main>
      <h2>{SITE_NAME} へようこそ</h2>
      <p>ここに本文を書きます。</p>
    </main>
    {{footer.html}}
  </body>
</html>

できること

共通パーツの読み込み

common/ 配下の HTML を {{...}} で読み込めます。

{{header.html}}
{{nested/footer.html}}

変数の差し込み

setting.jsonvariables 配下のキーを {...} で埋め込めます。

<title>{SITE_NAME}</title>

名前付きブロックの再利用

{{{ name: キー;内容 }}} をどこかのテキストファイルに書くと、その場でも 内容 が展開され、さらにほかの HTML / CSS / JS / テキストファイルから {{{{ key }}}} で再利用できます。

<!-- landing.html -->
{{{ name: hero;<section class="hero">{SITE_NAME}</section>}}}

<!-- about.html -->
<main>
  {{{{ hero }}}}
</main>
  • 既存の {{part.html}}{SETTING_KEY} と衝突しないよう、専用の 3 重 / 4 重ブレースだけを解釈します
  • ビルド前に名前付きブロックを 1 回収集してから展開するので、ファイルごとに再探索せず高速です
  • 再帰参照や未定義キーは警告を出して安全にスキップします

画像の自動変換

png / jpg / jpeg はビルド時に webp へ変換されます。 さらに HTML / CSS / JS のローカル画像参照も、対応する場合は .webp に書き換えられます。

setting.jsonbuild.webpExclude に配列でファイルパス(プロジェクトルート相対)を指定すると、その画像は変換対象外になります。

{
  "build": {
    "webpExclude": [
      "assets/no-convert.png",
      "images/hero.jpg"
    ]
  }
}

出力されるもの

mssgen はカレントディレクトリを再帰的に走査し、対象ファイルを dist/ に同じ構造で出力します。

ビルド対象からは次が除外されます。

  • dist/
  • node_modules/
  • .git/
  • common/
  • setting.json
  • package.json
  • package-lock.json

コマンド一覧

  • mssgen init: 初期ファイルを不足分だけ生成
  • mssgen: 本番用の dist/ を生成
  • mssgen dev: 監視つき開発サーバーを起動

npm install mssgen で導入した場合は、mssgen の代わりに npx mssgen を使ってください。

開発メモ

開発者向けの補足は DEV.md にあります。