Skip to content

chore(plugin): extract multi-locale plugin to npm package#34

Open
guilbep wants to merge 3 commits into
mainfrom
chore/extract-multi-locale-plugin-to-npm
Open

chore(plugin): extract multi-locale plugin to npm package#34
guilbep wants to merge 3 commits into
mainfrom
chore/extract-multi-locale-plugin-to-npm

Conversation

@guilbep
Copy link
Copy Markdown
Contributor

@guilbep guilbep commented May 26, 2026

Summary

  • Drops the vendored plugins/ directory; consumes vite-ssr-nunjucks-i18n-basic@^2.0.0 from npm instead.
  • vite.config.js imports createMultiLocalePlugin from the package.
  • Cleans dependencies the plugin used to need directly:
    • Removed from dependencies: chokidar, nunjucks (the plugin pulls these transitively now)
    • Removed from devDependencies: html-minifier-terser (transitive too)
    • Moved to devDependencies: glob (only scripts/generate-dev-webp.js uses it directly)

Plugin notes

The published package's behavior is byte-equivalent to the previous in-repo plugin, with one small portability fix: generators now load their bundled Nunjucks templates via import.meta.url instead of the CWD-relative "plugins/templates", so the package works regardless of where the consumer invokes Vite from. Each generator also uses an isolated nunjucks.Environment so it no longer mutates the user's global env.

Possible further cleanup (not done here)

These appear unreferenced in the codebase but were left in place in case they're staged for upcoming work — flag if you want them removed too:

  • @rollup/plugin-terser
  • cssnano
  • svgo

Test plan

  • npm install resolves to vite-ssr-nunjucks-i18n-basic@2.0.0 from npmjs.org (verified in package-lock.json)
  • npm run build produces the same dist/ output (16 HTML files across en/fr, sitemaps, root redirect, 404s, webmanifests, asset hashing)
  • CI checks pass
  • Manual smoke check of preview server (npm run preview)

🤖 Generated with Claude Code

  vite-ssr-nunjucks-i18n-basic npm package

  The plugin code previously vendored under plugins/ now lives in the
  vite-ssr-nunjucks-i18n-basic@2.0.0 package on npm. INPLUGS-CO2 consumes
  it as a regular dependency.

  Also drops chokidar, nunjucks, html-minifier-terser from dependencies
  (transitively provided by the plugin now), and moves glob to
  devDependencies (only the dev WebP script uses it directly).
Copilot AI review requested due to automatic review settings May 26, 2026 12:03
guilbep added 2 commits May 26, 2026 14:08
  2.0.1

  @rollup/plugin-terser, cssnano, and svgo have no direct references in the
  codebase. The plugin handles its own CSS/image processing, and Vite's
  'minify: terser' option pulls terser as a transitive dep where needed.

  Lockfile refreshes vite-ssr-nunjucks-i18n-basic from 2.0.0 to 2.0.1
  (per-locale 404 directory fix).
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR migrates the project from a vendored plugins/ multi-locale Vite plugin implementation to consuming the published vite-ssr-nunjucks-i18n-basic package from npm, and removes the in-repo plugin source/templates accordingly.

Changes:

  • Switches vite.config.js to import createMultiLocalePlugin from vite-ssr-nunjucks-i18n-basic.
  • Removes the vendored plugin implementation (plugins/ utilities, generators, and templates).
  • Updates package.json dependencies/devDependencies to reflect the move to the external package.

Reviewed changes

Copilot reviewed 15 out of 19 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
vite.config.js Replaces local plugin import with npm package import.
package.json Drops direct deps previously needed by the vendored plugin and adds the npm package dependency.
plugins/multi-locale-plugin.js Removes vendored multi-locale plugin implementation.
plugins/utils/page-renderer.js Removes vendored rendering utility (now provided by npm package).
plugins/utils/locale-utils.js Removes vendored locale utilities (now provided by npm package).
plugins/utils/asset-processor.js Removes vendored asset pipeline (now provided by npm package).
plugins/generators/sitemap-generator.js Removes vendored generator (now provided by npm package).
plugins/generators/notfound-generator.js Removes vendored generator (now provided by npm package).
plugins/generators/webmanifest-generator.js Removes vendored generator (now provided by npm package).
plugins/generators/root-redirect-generator.js Removes vendored generator (now provided by npm package).
plugins/templates/sitemap.xml.njk Removes vendored template (now provided by npm package).
plugins/templates/sitemap-index.xml.njk Removes vendored template (now provided by npm package).
plugins/templates/root-redirect.html.njk Removes vendored template (now provided by npm package).
plugins/templates/manifest.json.njk Removes vendored template (now provided by npm package).
plugins/templates/404.html.njk Removes vendored template (now provided by npm package).

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread vite.config.js
Comment on lines +3 to 4
import { createMultiLocalePlugin } from "vite-ssr-nunjucks-i18n-basic";

Comment thread package.json
Comment on lines 1 to 50
{
"name": "vite-ssr-nunjucks-i18n-basic",
"version": "1.0.1",
"type": "module",
"description": "A modern, fast, and SEO-friendly multi-locale static site generator powered by Vite and Nunjucks",
"main": "vite.config.js",
"keywords": [
"vite",
"nunjucks",
"i18n",
"internationalization",
"multi-locale",
"static-site-generator",
"ssg",
"templates",
"html",
"build-tool"
],
"author": "Pierre Guilbert <guilbep@example.com>",
"license": "MIT",
"repository": {
"type": "git",
"url": "https://github.com/guilbep/vite-ssr-nunjucks-i18n-basic.git"
},
"bugs": {
"url": "https://github.com/guilbep/vite-ssr-nunjucks-i18n-basic/issues"
},
"homepage": "https://github.com/guilbep/vite-ssr-nunjucks-i18n-basic#readme",
"scripts": {
"prepare": "lefthook install -f",
"test": "npm run build && node -e \"console.log('✅ Build test passed!')\"",
"start": "vite",
"dev": "npm run webp:dev && vite dev",
"dev:fast": "vite dev",
"webp:dev": "node scripts/generate-dev-webp.js",
"build": "vite build",
"preview": "vite preview",
"format": "prettier --write . && djlint src/**/*.njk --profile nunjucks --reformat",
"format:templates": "djlint src/**/*.njk --profile nunjucks --reformat",
"lint:commit": "commitlint --edit",
"lighthouse": "npm run build && lhci autorun",
"lighthouse:collect": "npm run build && lhci collect",
"lighthouse:upload": "lhci upload",
"lighthouse:quick": "./lighthouse-test.sh",
"perf": "npm run lighthouse"
},
"dependencies": {
"chokidar": "^3.6.0",
"echarts": "^6.0.0",
"glob": "^11.0.3",
"nunjucks": "^3.2.4"
"vite-ssr-nunjucks-i18n-basic": "^2.0.0"
},
Comment thread package.json
Comment on lines 51 to 63
"devDependencies": {
"@commitlint/cli": "^19.8.1",
"@commitlint/config-conventional": "^19.8.1",
"@lhci/cli": "^0.15.1",
"@rollup/plugin-terser": "^0.4.4",
"concurrently": "^9.2.0",
"cssnano": "^7.1.0",
"html-minifier-terser": "^7.2.0",
"glob": "^11.0.3",
"lefthook": "^1.12.3",
"lighthouse": "^12.8.1",
"prettier": "^3.6.2",
"sharp": "^0.34.3",
"svgo": "^4.0.0",
"terser": "^5.43.1",
"vite": "^7.1.3",
"wait-on": "^8.0.4"
Comment thread package.json
"echarts": "^6.0.0",
"glob": "^11.0.3",
"nunjucks": "^3.2.4"
"vite-ssr-nunjucks-i18n-basic": "^2.0.0"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants