Skip to content

Commit

Permalink
fix(scaffold): update module template
Browse files Browse the repository at this point in the history
  • Loading branch information
mkilpatrick committed Nov 7, 2024
1 parent f1c53a9 commit 7674d46
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 16 deletions.
21 changes: 8 additions & 13 deletions packages/pages/src/dev/server/server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,24 +56,19 @@ export const createServer = async (
module,
projectStructure
);
if (moduleInfo !== undefined) {
let vite;
// initialize using postCss if we have it
if (moduleInfo.postCssPath !== undefined) {
vite = await createViteServer({
...getViteServerConfig(projectStructure),
if (moduleInfo) {
let viteServerConfig = getViteServerConfig(projectStructure);
if (moduleInfo.postCssPath) {
viteServerConfig = {
...viteServerConfig,
css: {
postcss: moduleInfo.postCssPath,
},
});
} else {
vite = await createViteServer(getViteServerConfig(projectStructure));
}
// otherwise initialize without setting postcss
if (!vite) {
vite = await createViteServer(getViteServerConfig(projectStructure));
};
}

const vite = await createViteServer(viteServerConfig);

app.use(vite.middlewares);
app.use(errorMiddleware(vite));
app.use(
Expand Down
6 changes: 3 additions & 3 deletions packages/pages/src/scaffold/modules/templates.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@ export const moduleCode = (
const tailwind = useTailwind ? ` className="tailwind"` : ``;
const formattedModuleName = formatModuleName(moduleName);

return `import { Module, ModuleConfig, ModuleProps } from "@yext/pages/*";
return `import * as React from "react";
import { Module, ModuleConfig, ModuleProps } from "@yext/pages/*";
import { AnalyticsProvider } from "@yext/pages-components";
import "./index.css";
Expand All @@ -39,9 +40,8 @@ const ${formattedModuleName}: Module = () => {
return(
<AnalyticsProvider
apiKey="REPLACE_ME"
defaultCurrency="REPLACE_ME"
currency="REPLACE_ME"
templateData={templateData}
productionDomains={["REPLACE_ME"]}
>
<div${tailwind}>
Module
Expand Down

0 comments on commit 7674d46

Please sign in to comment.