A Vite plugin that enables webpack-style `webpackChunkName` magic comments for code splitting, allowing developers to name dynamic imports in Vite projects. Current stable version 1.0.4-beta.1 supports Vite 5 (v1.x) and Vite 4 or lower (v0.2.x). Key differentiator: provides a familiar webpack syntax for chunk naming on Vite/Rollup, with a simple manualChunksPlugin() API. Not for third-party packages; supports user-defined manual chunks via callback. Actively maintained with TypeScript types included.
npm install vite-plugin-webpackchunknameVerified import paths — ran on the pinned version, not inferred.
Configures the plugin in vite.config.ts with optional custom manual chunks, and demonstrates how to use webpackChunkName magic comments in dynamic imports.
Use v1.x for Vite 5, v0.2.x for Vite 4. Check your Vite version before installing.
Plugin cannot chunk node_modules packages; use Rollup manualChunks for that.
Pass manualChunks callback to manualChunksPlugin() instead of setting it in Vite config build.rollupOptions.output.manualChunks.
Add the include option to Components() as shown in the README.
Use import { manualChunksPlugin } from 'vite-plugin-webpackchunkname'.Use manualChunks rollup option for third-party packages.
Remove manualChunks from Vite config and use plugin option instead.