Skip to content

Commit

Permalink
chore: change plugins to makoPlugins
Browse files Browse the repository at this point in the history
  • Loading branch information
Jinbao1001 committed Jun 27, 2024
1 parent a113db8 commit da9315b
Show file tree
Hide file tree
Showing 6 changed files with 18 additions and 11 deletions.
8 changes: 7 additions & 1 deletion examples/ssr-demo/.umirc.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,13 @@ export default {
routePrefetch: {},
manifest: {},
clientLoader: {},
mako: {},
mako: {
plugins: [
{
load: () => {},
},
],
},
ssr: {
builder: 'mako',
},
Expand Down
2 changes: 0 additions & 2 deletions packages/preset-umi/src/commands/build.ts
Original file line number Diff line number Diff line change
Expand Up @@ -107,11 +107,9 @@ umi build --clean
react: {
runtime: shouldUseAutomaticRuntime ? 'automatic' : 'classic',
},
plugins: api.config.mako?.plugins,
config: {
outputPath: api.userConfig.outputPath || 'dist',
...api.config,
inlineCSS: {},
} as IServicePluginAPI['config'],
cwd: api.cwd,
entry,
Expand Down
1 change: 0 additions & 1 deletion packages/preset-umi/src/commands/dev/dev.ts
Original file line number Diff line number Diff line change
Expand Up @@ -357,7 +357,6 @@ PORT=8888 umi dev
react: {
runtime: shouldUseAutomaticRuntime ? 'automatic' : 'classic',
},
plugins: api.config.mako?.plugins,
config: {
outputPath: api.userConfig.outputPath || 'dist',
...api.config,
Expand Down
13 changes: 9 additions & 4 deletions packages/preset-umi/src/features/mako/mako.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,14 @@ export default (api: IApi) => {
schema({ zod }) {
return zod
.object({
plugins: zod.object({
load: zod.function(),
generateEnd: zod.function(),
}),
plugins: zod.array(
zod
.object({
load: zod.function(),
generateEnd: zod.function(),
})
.partial(),
),
})
.partial();
},
Expand All @@ -31,6 +35,7 @@ export default (api: IApi) => {
...memo,
mfsu: false,
hmrGuardian: false,
makoPlugins: memo.mako?.plugins || [],
};
});

Expand Down
3 changes: 1 addition & 2 deletions packages/preset-umi/src/features/ssr/mako/mako.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@ export const build = async (api: IApi) => {
entry: {
'umi.server': entry,
},
plugins: api.config.mako.plugins,
config: {
makoPlugins: api.config.mako.plugins,
...api.config,
jsMinifier: 'none',
hash: useHash,
Expand All @@ -35,7 +35,6 @@ export const build = async (api: IApi) => {
fileName: 'build-manifest.json',
},
devtool: false,
inlineCSS: {},
cjs: true,
dynamicImportToRequire: false,
},
Expand Down
2 changes: 1 addition & 1 deletion packages/preset-umi/src/features/ssr/ssr.ts
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ export default (api: IApi) => {
// mako builder need config manifest
if (memo.ssr.builder === 'mako') {
assert(
!memo.mako,
memo.mako,
`The \`ssr.builder mako\` config is now allowed when \`mako\` is enable!`,
);
memo.manifest ??= {};
Expand Down

0 comments on commit da9315b

Please sign in to comment.