Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: antd plugin support moment transformer #11018

Merged
merged 11 commits into from
Apr 25, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 30 additions & 0 deletions packages/plugins/src/antd.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
// import { PluginAPI } from '../../server/dist/server';
// packages/core/src/service/service.ts#L541
import { existsSync } from 'fs';
import { join } from 'path';
import { Service } from 'umi/dist/service/service';

const base = join(__dirname, '../../fixtures/service');

function buildService(opts: { name: string }) {
const cwd = join(base, opts.name);
const pluginPath = join(cwd, 'plugin.ts');

console.log(pluginPath);

return new Service({
cwd,
env: 'development',
defaultConfigFiles: ['.umirc.ts', 'config/config.ts'],
plugins: [(existsSync(pluginPath) && pluginPath) as string].filter(Boolean),
});
}
describe('antd plugin', () => {
it('config moment to add webpack plugin', async () => {
const service = buildService({ name: 'umi-env' });
const userConfig = await service.run({
name: 'WhatToSetToGetWebPackConfig?',
zombieJ marked this conversation as resolved.
Show resolved Hide resolved
});
console.log(userConfig);
});
});
7 changes: 5 additions & 2 deletions packages/plugins/src/antd.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,8 @@ export default (api: IApi) => {
appConfig: zod
.record(zod.any())
.describe('Only antd@5.1.0 is supported'),
// DatePicker & Calendar use moment version
momentPicker: zod.boolean().describe('Only antd@5.x is supported'),
})
.deepPartial();
},
Expand Down Expand Up @@ -89,9 +91,10 @@ export default (api: IApi) => {
// antd import
memo.alias.antd = pkgPath;

// moment > dayjs
// dayjs > moment
if (antd.dayjs) {
memo.alias.moment = dirname(require.resolve('dayjs/package.json'));
// @ant-design/moment-webpack-plugin
console.log('2333');
}

// antd 5 里面没有变量了,less 跑不起来。注入一份变量至少能跑起来
Expand Down