diff --git a/packages/docusaurus/src/server/__tests__/__snapshots__/config.test.ts.snap b/packages/docusaurus/src/server/__tests__/__snapshots__/config.test.ts.snap index 165c2e74ba6a..2c20bb59c885 100644 --- a/packages/docusaurus/src/server/__tests__/__snapshots__/config.test.ts.snap +++ b/packages/docusaurus/src/server/__tests__/__snapshots__/config.test.ts.snap @@ -5,11 +5,8 @@ exports[`loadSiteConfig website with .cjs siteConfig 1`] = ` "siteConfig": { "baseUrl": "/", "baseUrlIssueBanner": true, - "clientModules": [ - "foo.js", - ], + "clientModules": [], "customFields": {}, - "favicon": "img/docusaurus.ico", "i18n": { "defaultLocale": "en", "localeConfigs": {}, @@ -21,31 +18,21 @@ exports[`loadSiteConfig website with .cjs siteConfig 1`] = ` "onBrokenLinks": "throw", "onBrokenMarkdownLinks": "warn", "onDuplicateRoutes": "warn", - "organizationName": "endiliey", - "plugins": [ - [ - "@docusaurus/plugin-content-docs", - { - "path": "../docs", - }, - ], - "@docusaurus/plugin-content-pages", - ], + "plugins": [], "presets": [], - "projectName": "hello", "scripts": [], "staticDirectories": [ "static", ], "stylesheets": [], - "tagline": "Hello World", + "tagline": "", "themeConfig": {}, "themes": [], - "title": "Hello", + "title": "title", "titleDelimiter": "|", - "url": "https://docusaurus.io", + "url": "https://example.com", }, - "siteConfigPath": "/packages/docusaurus/src/server/__tests__/__fixtures__/simple-site/docusaurus.config.js", + "siteConfigPath": "/packages/docusaurus/src/server/__tests__/__fixtures__/config/docusaurus.config.cjs", } `; diff --git a/packages/docusaurus/src/server/__tests__/config.test.ts b/packages/docusaurus/src/server/__tests__/config.test.ts index ba713d997562..d66a56c4f325 100644 --- a/packages/docusaurus/src/server/__tests__/config.test.ts +++ b/packages/docusaurus/src/server/__tests__/config.test.ts @@ -20,9 +20,7 @@ describe('loadSiteConfig', () => { }); it('website with .cjs siteConfig', async () => { - const config = await loadSiteConfig({ - siteDir: path.join(__dirname, '__fixtures__', 'simple-site'), - }); + const config = await loadSiteConfig({siteDir}); expect(config).toMatchSnapshot(); expect(config).not.toEqual({}); }); diff --git a/packages/docusaurus/src/server/config.ts b/packages/docusaurus/src/server/config.ts index 7ea1eabf8340..8f2fa9c9129e 100644 --- a/packages/docusaurus/src/server/config.ts +++ b/packages/docusaurus/src/server/config.ts @@ -15,7 +15,7 @@ import type {LoadContext} from '@docusaurus/types'; async function findConfig(siteDir: string) { // We could support .mjs, .ts, etc. in the future - const candidates = ['.js', 'cjs'].map( + const candidates = ['.js', '.cjs'].map( (ext) => DEFAULT_CONFIG_FILE_NAME + ext, ); const configPath = await findAsyncSequential( @@ -24,7 +24,8 @@ async function findConfig(siteDir: string) { ); if (!configPath) { logger.error('No config file found.'); - logger.info`Expected one of:${candidates}You can provide a custom config path with the code=${'--config'} option.`; + logger.info`Expected one of:${candidates} +You can provide a custom config path with the code=${'--config'} option.`; throw new Error(); } return configPath; diff --git a/packages/docusaurus/src/server/index.ts b/packages/docusaurus/src/server/index.ts index 4417f0f7f515..90908237b04f 100644 --- a/packages/docusaurus/src/server/index.ts +++ b/packages/docusaurus/src/server/index.ts @@ -156,7 +156,7 @@ next build. You can clear all build artifacts (including this folder) with the const genSiteConfig = generate( generatedFilesDir, - DEFAULT_CONFIG_FILE_NAME, + `${DEFAULT_CONFIG_FILE_NAME}.mjs`, `/* * AUTOGENERATED - DON'T EDIT * Your edits in this file will be overwritten in the next build!