Skip to content

Commit

Permalink
fix: Execution order is different between prepare and build.
Browse files Browse the repository at this point in the history
  • Loading branch information
wattanx committed Jul 16, 2023
1 parent 1fab21c commit bdc08dd
Showing 1 changed file with 17 additions and 5 deletions.
22 changes: 17 additions & 5 deletions src/module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,20 @@ export default defineNuxtModule<ModuleOptions>({
});
}

async function createPandaContext() {
const ctx = await loadContext();

const { msg } = await emitArtifacts(ctx);

logger.log(msg);
}

nuxt.hook("app:templatesGenerated", async () => {
if (!nuxt.options._prepare) {
await createPandaContext();
}
});

nuxt.hook("prepare:types", async ({ tsConfig }) => {
// require tsconfig.json for panda css
const GeneratedBy = "// Generated by nuxt-pandacss";
Expand All @@ -85,11 +99,9 @@ export default defineNuxtModule<ModuleOptions>({
GeneratedBy + "\n" + JSON.stringify(tsConfig, null, 2)
);

const ctx = await loadContext();

const { msg } = await emitArtifacts(ctx);

logger.info(msg);
if (nuxt.options._prepare) {
await createPandaContext();
}
});
},
});
Expand Down

0 comments on commit bdc08dd

Please sign in to comment.