Skip to content

Commit

Permalink
feat: support headstartwp.config.js as well
Browse files Browse the repository at this point in the history
  • Loading branch information
nicholasio committed Nov 14, 2023
1 parent 15fe6fc commit 43bd247
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions packages/next/src/config/withHeadlessConfig.ts
Original file line number Diff line number Diff line change
Expand Up @@ -154,11 +154,16 @@ export function withHeadlessConfig(

webpack: (config, options) => {
const headlessConfigPath = `${process.cwd()}/headless.config.js`;
const headstartWpConfigPath = `${process.cwd()}/headstartwp.config.js`;

const configPath = fs.existsSync(headstartWpConfigPath)
? headstartWpConfigPath
: headlessConfigPath;

const importSetHeadlessConfig = `
import { setHeadstartWPConfig as __setHeadstartWPConfig } from '@headstartwp/core/utils';
import headlessConfig from '${headlessConfigPath}';
__setHeadstartWPConfig(headlessConfig);
import __headlessConfig from '${configPath}';
__setHeadstartWPConfig(__headlessConfig);
`;

// clear webpack cache whenever headless.config.js changes or one of the env files
Expand Down

0 comments on commit 43bd247

Please sign in to comment.