Installations
npm install antd-dayjs-webpack-plugin
Score
97.1
Supply Chain
76.7
Quality
76
Maintenance
100
Vulnerability
100
License
Releases
Unable to fetch releases
Developer
Developer Guide
Module System
CommonJS
Min. Node Version
Typescript Support
No
Node Version
12.20.0
NPM Version
6.14.8
Statistics
290 Stars
49 Commits
30 Forks
10 Watching
2 Branches
36 Contributors
Updated on 21 Aug 2024
Bundle Size
1.63 kB
Minified
779.00 B
Minified + Gzipped
Languages
JavaScript (100%)
Total Downloads
Cumulative downloads
Total Downloads
6,253,343
Last day
-8.8%
4,730
Compared to previous day
Last week
5.4%
26,736
Compared to previous week
Last month
10.6%
109,627
Compared to previous month
Last year
-21.2%
1,543,466
Compared to previous year
Daily Downloads
Weekly Downloads
Monthly Downloads
Yearly Downloads
antd-dayjs-webpack-plugin
A webpack plugin for Day.js. 一个 Day.js 的 Webpack 插件。
Replace Moment.js with Day.js in antd project in ONE step. Bundle size reduced from 65 kb -> 4.19 kb.
只需一步操作即可使用 Day.js 替换 Moment.js ,打包体积由 65 kb 优化至 4.19 kb。
Name | Size | Size gzip |
---|---|---|
Moment.js | 231 kb | 65.55 kb |
Day.js | 11.11 kb | 4.19 kb |
Usage 使用方法
- Install
npm i dayjs --save
. 安装dayjs
。 - Install
npm i antd-dayjs-webpack-plugin --save-dev
. 安装antd-dayjs-webpack-plugin
。 - Add an instance of the plugin to the webpack plugin configuration. 更新 webpack 配置。
Example 示例
1// webpack-config.js 2const AntdDayjsWebpackPlugin = require('antd-dayjs-webpack-plugin'); 3 4module.exports = { 5 // ... 6 plugins: [ 7 new AntdDayjsWebpackPlugin() 8 ] 9}; 10 11// index.js 12import 'dayjs/locale/zh-cn' 13dayjs.locale('zh-cn') 14// 如果要使用非"英语"语言,请在项目文件里引入对应的语言包 15// if using locale other than 'en', please load the locale file in advance
Ant Design 3.x Notice Ant Design 3.x 注意事项
If you are using this plugin in a Ant Design 3.x project, you have to config it manually. 如果在 Ant Design 3.x 的项目中使用本插件,需要传入以下配置。
1 plugins: [ 2 new AntdDayjsWebpackPlugin({ 3 preset: 'antdv3' 4 }) 5 ]
Configuration 配置
No configuration needed unless you know what these configs mean. 默认无需额外配置,除非有特殊需要。
Attribute | Description | Type | Accepted Values | Default |
---|---|---|---|---|
plugins | plugin name | Array[string] | all support plugins | [] |
replaceMoment | replace moment to dayjs with webpack alias config | Boolean | true / false | |
preset | name of preset configuration | String | 'antd' | 'antd' |
Preset 'antd' contains the following plugins and set replaceMoment
to true
, you can pass your own plugin config/ replaceMoment config to override it.
'antd' 预设包含以下插件,并开启了‘替换Moment’配置,你可以通过 plugin 选项来配置自定义的插件组合及‘替换Moment’配置。
1[ 2 'isSameOrBefore', 3 'isSameOrAfter', 4 'advancedFormat', 5 'customParseFormat', 6 'weekday', 7 'weekYear', 8 'weekOfYear', 9 'isMoment', 10 'localeData', 11 'localizedFormat', 12]
Notice 说明
- Day.js is a lightweight library with only 2kb size, but we have to use some other plugins to make full compatible to moment.js in Antd, so the final bundle size is 4.19 kb (Still small 😀)
- Day.js 是一个只有 2kb 的轻量级时间库,但为了完成对 moment.js 和 Antd 代码的替换,我们需要引入一些特殊的插件,这会使最终的体积变成 4.19 kb (但仍然很小呀😀 )
- If you are using preset
antdv3
in a Ant Design 3.x project, please note: Day.js is designed to be immutable, however, in order to make full compatible to moment.js in Antd 3.x, we have to use a plugin 🚨BadMutable
🚨 to make Day.js mutable. This's not good and not what we want, but there's no better option. With this plugin enabled, all setters will update the instance itself.
- 如果是在 Ant Design 3.x 项目中使用了
antdv3
配置,请注意: Day.js 被设计成不可变的对象,但是为了完成对 moment.js 的替换,必须要引入一个 🚨BadMutable
🚨插件让其变成可变对象,这并不是一个好的选择,但为了兼容也没有更好的办法。当使用这个插件后,所有的 setter 都会更新当前实例。
No vulnerabilities found.
Reason
no binaries found in the repo
Reason
0 existing vulnerabilities detected
Reason
Found 2/28 approved changesets -- score normalized to 0
Reason
0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
license file not detected
Details
- Warn: project does not have a license file
Reason
project is not fuzzed
Details
- Warn: no fuzzer integrations found
Reason
branch protection not enabled on development/release branches
Details
- Warn: branch protection not enabled for branch 'master'
Reason
security policy file not detected
Details
- Warn: no security policy file detected
- Warn: no security file to analyze
- Warn: no security file to analyze
- Warn: no security file to analyze
Reason
SAST tool is not run on all commits -- score normalized to 0
Details
- Warn: 0 commits out of 4 are checked with a SAST tool
Score
2.6
/10
Last Scanned on 2024-11-25
The Open Source Security Foundation is a cross-industry collaboration to improve the security of open source software (OSS). The Scorecard provides security health metrics for open source projects.
Learn MoreOther packages similar to antd-dayjs-webpack-plugin
antd-dayjs-vite-plugin
Day.js vite plugin for Ant Design (antd)
dayjs
2KB immutable date time library alternative to Moment.js with the same modern API
dayjs-plugin-utc
utc plugin for dayjs
@ant-design/moment-webpack-plugin
A webpack plugin to replace [Day.js](https://day.js.org/) to [Moment.js](http://momentjs.com/) automatically.