antd-dayjs-vite-plugin

raw JSON →
2.0.0 verified Mon Apr 27 auth: no javascript

Vite plugin that replaces Moment.js with Day.js in Ant Design (antd) to reduce bundle size. Current stable version is 2.0.0, requires dayjs >=1 and vite >=5. It is the Vite counterpart of antd-dayjs-webpack-plugin, offering the same configuration options. Key differentiator: directly swaps moment locales and plugins with dayjs equivalents at build time, no manual code changes needed.

error Error: [vite] Internal server error: Default import is not available in antd-dayjs-vite-plugin
cause Using default import with v2.0.0.
fix
Use named import: import { antdDayjs } from 'antd-dayjs-vite-plugin'.
error Error: Cannot find module 'antd-dayjs-vite-plugin'
cause Package not installed or incorrect path.
fix
Run npm install antd-dayjs-vite-plugin or check package.json.
error TypeError: antdDayjs is not a function
cause Importing as default in v1.x but v2.0.0 uses named export.
fix
Use import { antdDayjs } from 'antd-dayjs-vite-plugin'.
breaking v2.0.0 changed from default export to named export
fix Change import from `import antdDayjs from '...'` to `import { antdDayjs } from '...'`.
breaking Requires Vite >=5; incompatible with Vite 4
fix Upgrade Vite to version 5 or later, or use v1.x with Vite 4.
gotcha Plugin only affects antd components using moment. Custom moment usage remains unchanged
fix Manually replace `moment` imports with `dayjs` in your own code if needed.
gotcha Some edge cases with locale loading may break if dayjs plugins are not configured
fix Ensure dayjs locale and plugin (e.g., utc, advancedFormat) are explicitly imported if used by antd components.
npm install antd-dayjs-vite-plugin
yarn add antd-dayjs-vite-plugin
pnpm add antd-dayjs-vite-plugin

Minimal usage: add the plugin to vite config to replace moment with dayjs in antd.

import { defineConfig } from 'vite';
import { antdDayjs } from 'antd-dayjs-vite-plugin';

export default defineConfig({
  plugins: [antdDayjs()],
});