registration

This commit is contained in:
User
2025-02-02 16:08:03 +03:00
parent 7f6495eb4d
commit 78afbaed71
6334 changed files with 196774 additions and 165754 deletions

View File

@@ -16,11 +16,11 @@ export const supportedLocales = ["en-US", "de", "pl", "it"];
We could also have a function that formats the date:
```js
const getLocale = (locale) => import(`date-fns/locale/${locale}/index.js`); // or require() if using CommonJS
const getLocale = (locale) => import(`date-fns-locale/locale/${locale}.js`); // or require() if using CommonJS
const formatDate = (date, formatStyle, locale) => {
return format(date, formatStyle, {
locale: getLocale(locale),
locale: getLocale(locale).default,
});
};
```
@@ -30,17 +30,22 @@ In order to exclude unused languages we can use webpacks [ContextReplacementPlug
`webpack.config.js`:
```js
import webpack from 'webpack'
import { supportedLocales } from './config.js'
import webpack from "webpack";
import { supportedLocales } from "./config.js";
export default const config = {
export default config = {
resolve: {
alias: {
"date-fns-locale": path.dirname(require.resolve("date-fns/package.json")),
},
},
plugins: [
new webpack.ContextReplacementPlugin(
/^date-fns[/\\]locale$/,
new RegExp(`\\.[/\\\\](${supportedLocales.join('|')})[/\\\\]index\\.js$`)
)
]
}
/date-fns[/\\]locale/,
new RegExp(`(${locales.join("|")})\.js$`),
),
],
};
```
This results in a language bundle of ~23kb .