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

fix(scaffold): update module template #550

Merged
merged 1 commit into from
Nov 7, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
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
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
Loading