dayjs-webpack-plugin
Version: 
Day.js webpack plugin
43 lines (30 loc) • 1.32 kB
Markdown
[](https://www.npmjs.org/package/dayjs-webpack-plugin)
A webpack plugin for [dayjs](https://github.com/iamkun/dayjs). 
- Pre-pack all the needed plugins and locales. 
- Auto replace `moment` with `dayjs` in source code.
1. Install `dayjs-webpack-plugin`.
1. Add an instance of the plugin to the webpack plugin configuration.
```js
import DayjsWebpackPlugin from 'dayjs-webpack-plugin';
const configuration = {
  plugins: ['utc'],
  locales: ['zh-cn'],
  replaceMoment: true
};
module.exports = {
  // ...
  plugins: [
    new DayjsWebpackPlugin(configuration)
  ]
};
```
| Attribute      | Description          | Type      | Accepted Values       | Default  |
| ----------------- | -------------------------------- | --------------- | ------ | ------ |
| plugins           | plugin name    | Array[string]          |   all support plugins    |    []    |
| locales              | locale name                | Array[string] | all support locales | []  |
| replaceMoment              | replace moment to dayjs with webpack alias config  | Boolean | true / false | false  |
| preset              | name of preset configuration                   | String | antd | -  |