fixed dayjs to moment bug with webpack plugin
This commit is contained in:
@@ -2,6 +2,32 @@
|
|||||||
const TerserPlugin = require("terser-webpack-plugin");
|
const TerserPlugin = require("terser-webpack-plugin");
|
||||||
const SentryWebpackPlugin = require("@sentry/webpack-plugin");
|
const SentryWebpackPlugin = require("@sentry/webpack-plugin");
|
||||||
|
|
||||||
|
const generateRegExp = /generate\/dayjs/;
|
||||||
|
const updateResource = (resource) => {
|
||||||
|
resource.request = resource.request.replace("dayjs", "moment");
|
||||||
|
};
|
||||||
|
const plugin = "AntdMomentWebpackPlugin";
|
||||||
|
class AntdMomentWebpackPlugin {
|
||||||
|
constructor(options) {
|
||||||
|
this.options = options || {};
|
||||||
|
}
|
||||||
|
apply(compiler) {
|
||||||
|
compiler.hooks.normalModuleFactory.tap(plugin, (factory) => {
|
||||||
|
factory.hooks.beforeResolve.tap(plugin, (result) => {
|
||||||
|
if (generateRegExp.test(result.request)) {
|
||||||
|
updateResource(result);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
factory.hooks.afterResolve.tap(plugin, (result) => {
|
||||||
|
const createData = result.createData;
|
||||||
|
if (generateRegExp.test(createData.resource)) {
|
||||||
|
updateResource(result);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
plugins: [
|
plugins: [
|
||||||
{
|
{
|
||||||
@@ -21,6 +47,7 @@ module.exports = {
|
|||||||
},
|
},
|
||||||
],
|
],
|
||||||
webpack: {
|
webpack: {
|
||||||
|
plugins: [new AntdMomentWebpackPlugin()],
|
||||||
configure: (webpackConfig) => ({
|
configure: (webpackConfig) => ({
|
||||||
...webpackConfig,
|
...webpackConfig,
|
||||||
optimization: {
|
optimization: {
|
||||||
|
|||||||
@@ -13,7 +13,7 @@
|
|||||||
"@sentry/tracing": "^7.40.0",
|
"@sentry/tracing": "^7.40.0",
|
||||||
"@splitsoftware/splitio-react": "^1.8.1",
|
"@splitsoftware/splitio-react": "^1.8.1",
|
||||||
"@tanem/react-nprogress": "^5.0.8",
|
"@tanem/react-nprogress": "^5.0.8",
|
||||||
"antd": "5.1.5",
|
"antd": "^5.4.2",
|
||||||
"apollo-link-logger": "^2.0.0",
|
"apollo-link-logger": "^2.0.0",
|
||||||
"axios": "^1.3.4",
|
"axios": "^1.3.4",
|
||||||
"dinero.js": "^1.9.1",
|
"dinero.js": "^1.9.1",
|
||||||
@@ -114,6 +114,7 @@
|
|||||||
"react-error-overlay": "6.0.9"
|
"react-error-overlay": "6.0.9"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
|
"@ant-design/moment-webpack-plugin": "^0.0.3",
|
||||||
"@sentry/webpack-plugin": "^1.20.0",
|
"@sentry/webpack-plugin": "^1.20.0",
|
||||||
"@testing-library/cypress": "^9.0.0",
|
"@testing-library/cypress": "^9.0.0",
|
||||||
"cypress": "^12.3.0",
|
"cypress": "^12.3.0",
|
||||||
|
|||||||
18160
client/yarn.lock
18160
client/yarn.lock
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user