chore(plugin): extract multi-locale plugin to npm package#34
Open
guilbep wants to merge 3 commits into
Open
Conversation
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).
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).
Contributor
There was a problem hiding this comment.
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.jsto importcreateMultiLocalePluginfromvite-ssr-nunjucks-i18n-basic. - Removes the vendored plugin implementation (
plugins/utilities, generators, and templates). - Updates
package.jsondependencies/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 on lines
+3
to
4
| import { createMultiLocalePlugin } from "vite-ssr-nunjucks-i18n-basic"; | ||
|
|
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 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" |
| "echarts": "^6.0.0", | ||
| "glob": "^11.0.3", | ||
| "nunjucks": "^3.2.4" | ||
| "vite-ssr-nunjucks-i18n-basic": "^2.0.0" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
plugins/directory; consumesvite-ssr-nunjucks-i18n-basic@^2.0.0from npm instead.vite.config.jsimportscreateMultiLocalePluginfrom the package.dependencies:chokidar,nunjucks(the plugin pulls these transitively now)devDependencies:html-minifier-terser(transitive too)devDependencies:glob(onlyscripts/generate-dev-webp.jsuses 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.urlinstead of the CWD-relative"plugins/templates", so the package works regardless of where the consumer invokes Vite from. Each generator also uses an isolatednunjucks.Environmentso 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-tersercssnanosvgoTest plan
npm installresolves tovite-ssr-nunjucks-i18n-basic@2.0.0from npmjs.org (verified in package-lock.json)npm run buildproduces the samedist/output (16 HTML files across en/fr, sitemaps, root redirect, 404s, webmanifests, asset hashing)npm run preview)🤖 Generated with Claude Code