Skip to content

armgit / core

Public Imported from GitHub
0

100% open-source IoT Platform - Integrate your devices, add intelligence, build custom apps

Add webpack plugin to remove moment.js locales we do not support (#2429)

Martin Peetersdab23bf0046b
diff --git a/ui/util/package.json b/ui/util/package.json
index 0efccc380..00bc085c7 100644
--- a/ui/util/package.json
+++ b/ui/util/package.json
@@ -27,6 +27,7 @@
"eslint-plugin-node": "^11.1.0",
"eslint-plugin-promise": "^6.0.0",
"html-webpack-plugin": "^5.6.3",
+ "moment-locales-webpack-plugin": "^1.2.0",
"prettier": "^2.5.1",
"querystring-es3": "^0.2.1",
"shx": "~0.4.0",
diff --git a/ui/util/webpack.util.js b/ui/util/webpack.util.js
index 7303b4ca8..06bd957b2 100644
--- a/ui/util/webpack.util.js
+++ b/ui/util/webpack.util.js
@@ -2,6 +2,7 @@ const fs = require("fs");
const path = require("path");
const { rspack } = require('@rspack/core');
const HtmlWebpackPlugin = require("html-webpack-plugin");
+const MomentLocalesPlugin = require('moment-locales-webpack-plugin');
function getStandardModuleRules() {
return {
@@ -100,7 +101,11 @@ function getAppConfig(mode, isDevServer, dirname, managerUrl, keycloakUrl, port)
chunksSortMode: 'none',
inject: false,
template: 'index.html'
- })
+ }),
+ // Remove any unused locales
+ new MomentLocalesPlugin({
+ localesToKeep: ['ar', 'zh-cn', 'de', 'en', 'es', 'fr', 'it', 'nl', 'pt', 'ro', 'uk'],
+ }),
];
if (production) {
diff --git a/yarn.lock b/yarn.lock
index 356f7b65e..b9e5717d7 100644
--- a/yarn.lock
+++ b/yarn.lock
@@ -2354,6 +2354,7 @@ __metadata:
eslint-plugin-node: "npm:^11.1.0"
eslint-plugin-promise: "npm:^6.0.0"
html-webpack-plugin: "npm:^5.6.3"
+ moment-locales-webpack-plugin: "npm:^1.2.0"
prettier: "npm:^2.5.1"
querystring-es3: "npm:^0.2.1"
shx: "npm:~0.4.0"
@@ -8269,6 +8270,13 @@ __metadata:
languageName: node
linkType: hard
+"lodash.difference@npm:^4.5.0":
+ version: 4.5.0
+ resolution: "lodash.difference@npm:4.5.0"
+ checksum: 10c0/5d52859218a7df427547ff1fadbc397879709fe6c788b037df7d6d92b676122c92bd35ec85d364edb596b65dfc6573132f420c9b4ee22bb6b9600cd454c90637
+ languageName: node
+ linkType: hard
+
"lodash.memoize@npm:^4.1.2":
version: 4.1.2
resolution: "lodash.memoize@npm:4.1.2"
@@ -8654,6 +8662,18 @@ __metadata:
languageName: node
linkType: hard
+"moment-locales-webpack-plugin@npm:^1.2.0":
+ version: 1.2.0
+ resolution: "moment-locales-webpack-plugin@npm:1.2.0"
+ dependencies:
+ lodash.difference: "npm:^4.5.0"
+ peerDependencies:
+ moment: ^2.8.0
+ webpack: ^1 || ^2 || ^3 || ^4 || ^5
+ checksum: 10c0/610c41c77d09e2d1bd8dd412493a3396c3e151080117939357a13b91a71e7782c44ee6405739a11d6ad7dfaf41179ca5eb770d79e3fbf2bf091f10088f0557a7
+ languageName: node
+ linkType: hard
+
"moment@npm:2.29.4":
version: 2.29.4
resolution: "moment@npm:2.29.4"