@strapi/strapi 5.48.1 → 5.49.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/admin.js +17 -7
- package/dist/admin.js.map +1 -1
- package/dist/node/create-build-context.d.ts +0 -4
- package/dist/node/create-build-context.d.ts.map +1 -1
- package/dist/node/vite/config.d.ts.map +1 -1
- package/dist/node/vite/resolve-development-config.test.d.ts +2 -0
- package/dist/node/vite/resolve-development-config.test.d.ts.map +1 -0
- package/dist/node/vite/watch.d.ts.map +1 -1
- package/dist/package.json.js +1 -1
- package/dist/package.json.mjs +1 -1
- package/dist/src/cli/commands/admin/active-user.js +6 -2
- package/dist/src/cli/commands/admin/active-user.js.map +1 -1
- package/dist/src/cli/commands/admin/block-user.js +6 -2
- package/dist/src/cli/commands/admin/block-user.js.map +1 -1
- package/dist/src/cli/commands/admin/create-user.js +5 -1
- package/dist/src/cli/commands/admin/create-user.js.map +1 -1
- package/dist/src/cli/commands/admin/delete-user.js +6 -2
- package/dist/src/cli/commands/admin/delete-user.js.map +1 -1
- package/dist/src/cli/commands/admin/list-users.js +16 -11
- package/dist/src/cli/commands/admin/list-users.js.map +1 -1
- package/dist/src/cli/commands/admin/reset-user-password.js +6 -2
- package/dist/src/cli/commands/admin/reset-user-password.js.map +1 -1
- package/dist/src/cli/commands/components/list.js +7 -2
- package/dist/src/cli/commands/components/list.js.map +1 -1
- package/dist/src/cli/commands/configuration/dump.js +5 -1
- package/dist/src/cli/commands/configuration/dump.js.map +1 -1
- package/dist/src/cli/commands/configuration/restore.js +8 -3
- package/dist/src/cli/commands/configuration/restore.js.map +1 -1
- package/dist/src/cli/commands/console.js +5 -1
- package/dist/src/cli/commands/console.js.map +1 -1
- package/dist/src/cli/commands/content-types/list.js +7 -2
- package/dist/src/cli/commands/content-types/list.js.map +1 -1
- package/dist/src/cli/commands/controllers/list.js +7 -2
- package/dist/src/cli/commands/controllers/list.js.map +1 -1
- package/dist/src/cli/commands/develop.js +5 -1
- package/dist/src/cli/commands/develop.js.map +1 -1
- package/dist/src/cli/commands/export/action.js +11 -5
- package/dist/src/cli/commands/export/action.js.map +1 -1
- package/dist/src/cli/commands/hooks/list.js +7 -2
- package/dist/src/cli/commands/hooks/list.js.map +1 -1
- package/dist/src/cli/commands/import/action.js +7 -2
- package/dist/src/cli/commands/import/action.js.map +1 -1
- package/dist/src/cli/commands/import/command.js +6 -2
- package/dist/src/cli/commands/import/command.js.map +1 -1
- package/dist/src/cli/commands/middlewares/list.js +7 -2
- package/dist/src/cli/commands/middlewares/list.js.map +1 -1
- package/dist/src/cli/commands/openapi/generate.js +17 -11
- package/dist/src/cli/commands/openapi/generate.js.map +1 -1
- package/dist/src/cli/commands/policies/list.js +7 -2
- package/dist/src/cli/commands/policies/list.js.map +1 -1
- package/dist/src/cli/commands/routes/list.js +8 -3
- package/dist/src/cli/commands/routes/list.js.map +1 -1
- package/dist/src/cli/commands/services/list.js +7 -2
- package/dist/src/cli/commands/services/list.js.map +1 -1
- package/dist/src/cli/commands/start.js +8 -3
- package/dist/src/cli/commands/start.js.map +1 -1
- package/dist/src/cli/commands/telemetry/disable.js +14 -9
- package/dist/src/cli/commands/telemetry/disable.js.map +1 -1
- package/dist/src/cli/commands/telemetry/enable.js +14 -9
- package/dist/src/cli/commands/telemetry/enable.js.map +1 -1
- package/dist/src/cli/commands/transfer/action.js +5 -1
- package/dist/src/cli/commands/transfer/action.js.map +1 -1
- package/dist/src/cli/commands/ts/generate-types.js +5 -1
- package/dist/src/cli/commands/ts/generate-types.js.map +1 -1
- package/dist/src/cli/utils/commander.js +5 -1
- package/dist/src/cli/utils/commander.js.map +1 -1
- package/dist/src/cli/utils/data-transfer.js +28 -21
- package/dist/src/cli/utils/data-transfer.js.map +1 -1
- package/dist/src/cli/utils/helpers.js +7 -3
- package/dist/src/cli/utils/helpers.js.map +1 -1
- package/dist/src/cli/utils/logger.js +15 -10
- package/dist/src/cli/utils/logger.js.map +1 -1
- package/dist/src/cli/utils/tsconfig.js +9 -4
- package/dist/src/cli/utils/tsconfig.js.map +1 -1
- package/dist/src/node/build.js +3 -2
- package/dist/src/node/build.js.map +1 -1
- package/dist/src/node/core/admin-customisations.js +6 -2
- package/dist/src/node/core/admin-customisations.js.map +1 -1
- package/dist/src/node/core/aliases.js +5 -1
- package/dist/src/node/core/aliases.js.map +1 -1
- package/dist/src/node/core/config.js +5 -1
- package/dist/src/node/core/config.js.map +1 -1
- package/dist/src/node/core/dependencies.js +33 -22
- package/dist/src/node/core/dependencies.js.map +1 -1
- package/dist/src/node/core/ensure-admin-dependencies.js +5 -1
- package/dist/src/node/core/ensure-admin-dependencies.js.map +1 -1
- package/dist/src/node/core/env.js +7 -2
- package/dist/src/node/core/env.js.map +1 -1
- package/dist/src/node/core/errors.js +9 -3
- package/dist/src/node/core/errors.js.map +1 -1
- package/dist/src/node/core/files.js +6 -2
- package/dist/src/node/core/files.js.map +1 -1
- package/dist/src/node/core/linked-packages.js +5 -1
- package/dist/src/node/core/linked-packages.js.map +1 -1
- package/dist/src/node/core/monorepo.js +8 -3
- package/dist/src/node/core/monorepo.js.map +1 -1
- package/dist/src/node/core/plugins.js +17 -10
- package/dist/src/node/core/plugins.js.map +1 -1
- package/dist/src/node/core/resolve-module.js +8 -3
- package/dist/src/node/core/resolve-module.js.map +1 -1
- package/dist/src/node/create-build-context.js +16 -9
- package/dist/src/node/create-build-context.js.map +1 -1
- package/dist/src/node/create-build-context.mjs.map +1 -1
- package/dist/src/node/develop.js +14 -8
- package/dist/src/node/develop.js.map +1 -1
- package/dist/src/node/staticFiles.js +11 -5
- package/dist/src/node/staticFiles.js.map +1 -1
- package/dist/src/node/vite/config.js +14 -3
- package/dist/src/node/vite/config.js.map +1 -1
- package/dist/src/node/vite/config.mjs +9 -2
- package/dist/src/node/vite/config.mjs.map +1 -1
- package/dist/src/node/vite/watch.js +7 -62
- package/dist/src/node/vite/watch.js.map +1 -1
- package/dist/src/node/vite/watch.mjs +2 -62
- package/dist/src/node/vite/watch.mjs.map +1 -1
- package/dist/src/node/webpack/build.js +5 -1
- package/dist/src/node/webpack/build.js.map +1 -1
- package/dist/src/node/webpack/config.js +17 -8
- package/dist/src/node/webpack/config.js.map +1 -1
- package/dist/src/node/webpack/watch.js +11 -4
- package/dist/src/node/webpack/watch.js.map +1 -1
- package/package.json +22 -22
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"develop.js","sources":["../../../src/node/develop.ts"],"sourcesContent":["import fs from 'node:fs/promises';\nimport path from 'node:path';\nimport cluster from 'node:cluster';\n\nimport type chokidarType from 'chokidar';\nimport type { createStrapi as CreateStrapi } from '@strapi/core';\nimport type { CLIContext } from '../cli/types';\nimport { handleAdminDependencies } from './core/ensure-admin-dependencies';\nimport { getTimer, prettyTime, type TimeMeasurer } from './core/timer';\nimport type { WebpackWatcher } from './webpack/watch';\nimport type { ViteWatcher } from './vite/watch';\nimport type { Logger } from '../cli/utils/logger';\n\n// Lazy: worker-only deps; primary cluster process should not pay for them\nconst lazy = <T>(spec: string): (() => T) => {\n let cached: T | undefined;\n return (): T => {\n if (cached === undefined) {\n // eslint-disable-next-line @typescript-eslint/no-var-requires\n cached = require(spec);\n }\n return cached as T;\n };\n};\nconst tsUtils = lazy<typeof import('@strapi/typescript-utils')>('@strapi/typescript-utils');\nconst utils = lazy<typeof import('@strapi/utils')>('@strapi/utils');\nconst chokidar = lazy<typeof chokidarType>('chokidar');\nconst core = lazy<typeof import('@strapi/core')>('@strapi/core');\nconst buildCtx = lazy<typeof import('./create-build-context')>('./create-build-context');\nconst staticFs = lazy<typeof import('./staticFiles')>('./staticFiles');\n\ninterface DevelopOptions extends CLIContext {\n /**\n * Which bundler to use for building.\n *\n * @default webpack\n */\n bundler?: 'webpack' | 'vite';\n polling?: boolean;\n open?: boolean;\n watchAdmin?: boolean;\n buildAdmin?: boolean;\n /**\n * Auto-install missing admin dependencies\n *\n * @default true\n */\n installDeps?: boolean;\n}\n\n// This method removes all non-admin build files from the dist directory\nconst cleanupDistDirectory = async ({\n tsconfig,\n logger,\n timer,\n}: Pick<DevelopOptions, 'tsconfig' | 'logger'> & { timer: TimeMeasurer }) => {\n const distDir = tsconfig?.config?.options?.outDir;\n\n if (\n !distDir || // we don't have a dist dir\n (await fs\n .access(distDir)\n .then(() => false)\n .catch(() => true)) // it doesn't exist -- if it does but no access, that will be caught later\n ) {\n return;\n }\n\n const timerName = `cleaningDist${Date.now()}`;\n timer.start(timerName);\n const cleaningSpinner = logger.spinner(`Cleaning dist dir ${distDir}`).start();\n\n try {\n const dirContent = await fs.readdir(distDir);\n const validFilenames = dirContent\n // Ignore the admin build folder and the TypeScript incremental cache\n .filter((filename) => filename !== 'build' && !filename.endsWith('.tsbuildinfo'));\n for (const filename of validFilenames) {\n await fs.rm(path.resolve(distDir, filename), { recursive: true });\n }\n } catch (err: unknown) {\n const generatingDuration = timer.end(timerName);\n cleaningSpinner.text = `Error cleaning dist dir: ${err} (${prettyTime(generatingDuration)})`;\n cleaningSpinner?.fail();\n return;\n }\n\n const generatingDuration = timer.end(timerName);\n cleaningSpinner.text = `Cleaning dist dir (${prettyTime(generatingDuration)})`;\n cleaningSpinner?.succeed();\n};\n\nconst develop = async ({\n cwd,\n polling,\n logger,\n tsconfig,\n watchAdmin,\n buildAdmin,\n installDeps = true,\n ...options\n}: DevelopOptions) => {\n const timer = getTimer();\n\n if (cluster.isPrimary) {\n const shouldContinue = await handleAdminDependencies({\n cwd,\n logger,\n installIfMissing: installDeps,\n });\n\n if (!shouldContinue) {\n return;\n }\n\n if (tsconfig?.config) {\n // Build without diagnostics in case schemas have changed\n await cleanupDistDirectory({ tsconfig, logger, timer });\n try {\n await tsUtils().compile(cwd, { configOptions: { ignoreDiagnostics: true } });\n } catch (err: unknown) {\n logger.error(`Error during initial TypeScript compilation: ${(err as Error).message}`);\n // We don't return here because we want to attempt to start the server even if the initial compilation fails, as it can be fixed while the server is running\n }\n }\n\n /**\n * IF we're not watching the admin we're going to build it, this makes\n * sure that at least the admin is built for users & they can interact\n * with the application.\n */\n if (!watchAdmin && buildAdmin) {\n timer.start('createBuildContext');\n const contextSpinner = logger.spinner(`Building build context`).start();\n console.log('');\n\n const ctx = await buildCtx().createBuildContext({\n cwd,\n logger,\n tsconfig,\n options,\n });\n const contextDuration = timer.end('createBuildContext');\n contextSpinner.text = `Building build context (${prettyTime(contextDuration)})`;\n contextSpinner.succeed();\n\n timer.start('creatingAdmin');\n const adminSpinner = logger.spinner(`Creating admin`).start();\n\n await staticFs().writeStaticClientFiles(ctx);\n\n if (ctx.bundler === 'webpack') {\n const { build: buildWebpack } = await import('./webpack/build');\n await buildWebpack(ctx);\n } else if (ctx.bundler === 'vite') {\n const { build: buildVite } = await import('./vite/build');\n await buildVite(ctx);\n }\n\n const adminDuration = timer.end('creatingAdmin');\n adminSpinner.text = `Creating admin (${prettyTime(adminDuration)})`;\n adminSpinner.succeed();\n }\n\n cluster.on('message', async (worker, message) => {\n switch (message) {\n case 'reload': {\n if (tsconfig?.config) {\n try {\n // Build without diagnostics in case schemas have changed\n await cleanupDistDirectory({ tsconfig, logger, timer });\n await tsUtils().compile(cwd, { configOptions: { ignoreDiagnostics: true } });\n } catch (err: unknown) {\n const message = err instanceof Error ? err.message : String(err);\n logger.error(`Error during TypeScript compilation on reload: ${message}`);\n process.exit(1);\n }\n }\n logger.debug('cluster has the reload message, sending the worker kill message');\n worker.send('kill');\n break;\n }\n case 'killed': {\n logger.debug('cluster has the killed message, forking the cluster');\n cluster.fork();\n break;\n }\n case 'stop': {\n process.exit(1);\n break;\n }\n default:\n break;\n }\n });\n\n cluster.fork();\n }\n\n if (cluster.isWorker) {\n timer.start('loadStrapi');\n const loadStrapiSpinner = logger.spinner(`Loading Strapi`).start();\n\n const strapi = core().createStrapi({\n appDir: cwd,\n distDir: tsconfig?.config.options.outDir ?? '',\n autoReload: true,\n serveAdminPanel: !watchAdmin,\n });\n\n /**\n * If we're watching the admin panel then we're going to attach the watcher\n * as a strapi middleware.\n */\n let bundleWatcher: WebpackWatcher | ViteWatcher | undefined;\n\n const strapiInstance = await strapi.load();\n\n const contextSpinner = logger.spinner(`Building build context`);\n const adminSpinner = logger.spinner(`Creating admin`);\n const generatingTsSpinner = logger.spinner(`Generating types`);\n const compilingTsSpinner = logger.spinner(`Compiling TS`);\n\n let watcherStarted = false;\n const ensureWatcher = () => {\n if (!watcherStarted) {\n watcherStarted = true;\n startWatcher(strapiInstance, cwd, polling ?? false, logger, bundleWatcher);\n }\n };\n\n try {\n if (watchAdmin) {\n timer.start('createBuildContext');\n contextSpinner.start();\n\n const ctx = await buildCtx().createBuildContext({\n cwd,\n logger,\n strapi,\n tsconfig,\n options,\n });\n const contextDuration = timer.end('createBuildContext');\n contextSpinner.text = `Building build context (${prettyTime(contextDuration)})`;\n contextSpinner.succeed();\n\n timer.start('creatingAdmin');\n adminSpinner.start();\n\n await staticFs().writeStaticClientFiles(ctx);\n\n if (ctx.bundler === 'webpack') {\n const { watch: watchWebpack } = await import('./webpack/watch');\n bundleWatcher = await watchWebpack(ctx);\n } else if (ctx.bundler === 'vite') {\n const { watch: watchVite } = await import('./vite/watch');\n bundleWatcher = await watchVite(ctx);\n }\n\n const adminDuration = timer.end('creatingAdmin');\n adminSpinner.text = `Creating admin (${prettyTime(adminDuration)})`;\n adminSpinner.succeed();\n }\n\n const loadStrapiDuration = timer.end('loadStrapi');\n loadStrapiSpinner.text = `Loading Strapi (${prettyTime(loadStrapiDuration)})`;\n loadStrapiSpinner.succeed();\n\n // For TS projects, type generation is a requirement for the develop command so that the server can restart\n // For JS projects, we respect the experimental autogenerate setting\n if (tsconfig?.config || strapi.config.get('typescript.autogenerate') !== false) {\n timer.start('generatingTS');\n generatingTsSpinner.start();\n\n await tsUtils().generators.generate({\n strapi: strapiInstance,\n pwd: cwd,\n rootDir: undefined,\n logger: { silent: true, debug: false },\n artifacts: { contentTypes: true, components: true },\n });\n\n const generatingDuration = timer.end('generatingTS');\n generatingTsSpinner.text = `Generating types (${prettyTime(generatingDuration)})`;\n generatingTsSpinner.succeed();\n }\n\n if (tsconfig?.config) {\n timer.start('compilingTS');\n compilingTsSpinner.start();\n\n await cleanupDistDirectory({ tsconfig, logger, timer });\n await tsUtils().compile(cwd, { configOptions: { ignoreDiagnostics: false } });\n\n const compilingDuration = timer.end('compilingTS');\n compilingTsSpinner.text = `Compiling TS (${prettyTime(compilingDuration)})`;\n compilingTsSpinner.succeed();\n }\n\n ensureWatcher();\n\n strapiInstance.start();\n } catch (err: unknown) {\n const message = err instanceof Error ? err.message : String(err);\n logger.error(`Error during development: ${message}`);\n\n if (loadStrapiSpinner.isSpinning) {\n loadStrapiSpinner.fail();\n }\n // Fail any spinners that were left running.\n if (contextSpinner.isSpinning) {\n contextSpinner.fail();\n }\n if (compilingTsSpinner.isSpinning) {\n compilingTsSpinner.fail();\n }\n if (adminSpinner.isSpinning) {\n adminSpinner.fail();\n }\n if (generatingTsSpinner.isSpinning) {\n generatingTsSpinner.fail();\n }\n\n ensureWatcher();\n }\n }\n};\n\nfunction startWatcher(\n strapiInstance: Awaited<ReturnType<typeof CreateStrapi>>,\n cwd: string,\n polling: boolean,\n logger: Logger,\n bundleWatcher?: WebpackWatcher | ViteWatcher\n) {\n const restart = async () => {\n if (strapiInstance.reload.isWatching && !strapiInstance.reload.isReloading) {\n strapiInstance.reload.isReloading = true;\n strapiInstance.reload();\n }\n };\n\n const watcher = chokidar()\n .watch(cwd, {\n ignoreInitial: true,\n usePolling: polling,\n ignored: [\n /(^|[/\\\\])\\../, // dot files\n /tmp/,\n '**/src/admin/**',\n '**/src/plugins/**/admin/**',\n '**/dist/src/plugins/test/admin/**',\n '**/documentation',\n '**/documentation/**',\n '**/node_modules',\n '**/node_modules/**',\n '**/plugins.json',\n '**/build',\n '**/build/**',\n '**/log',\n '**/log/**',\n '**/logs',\n '**/logs/**',\n '**/*.log',\n '**/index.html',\n '**/public',\n '**/public/**',\n strapiInstance.dirs.static.public,\n utils().strings.joinBy('/', strapiInstance.dirs.static.public, '**'),\n '**/*.db*',\n '**/exports/**',\n '**/dist/**',\n '**/*.d.ts',\n '**/.yalc/**',\n '**/yalc.lock',\n // TODO v6: watch only src folder by default, and flip this to watchIncludeFiles\n ...strapiInstance.config.get('admin.watchIgnoreFiles', []),\n ],\n })\n .on('add', (path) => {\n strapiInstance.log.info(`File created: ${path}`);\n restart();\n })\n .on('change', (path) => {\n strapiInstance.log.info(`File changed: ${path}`);\n restart();\n })\n .on('unlink', (path) => {\n strapiInstance.log.info(`File deleted: ${path}`);\n restart();\n });\n\n process.on('message', async (message) => {\n switch (message) {\n case 'kill': {\n logger.debug(\n 'child process has the kill message, destroying the strapi instance and sending the killed process message'\n );\n await watcher.close();\n\n await strapiInstance.destroy();\n\n if (bundleWatcher) {\n bundleWatcher.close();\n }\n process.send?.('killed');\n break;\n }\n default:\n break;\n }\n });\n}\n\nexport { develop };\nexport type { DevelopOptions };\n"],"names":["lazy","spec","cached","undefined","require","tsUtils","utils","chokidar","core","buildCtx","staticFs","cleanupDistDirectory","tsconfig","logger","timer","distDir","config","options","outDir","fs","access","then","catch","timerName","Date","now","start","cleaningSpinner","spinner","dirContent","readdir","validFilenames","filter","filename","endsWith","rm","path","resolve","recursive","err","generatingDuration","end","text","prettyTime","fail","succeed","develop","cwd","polling","watchAdmin","buildAdmin","installDeps","getTimer","cluster","isPrimary","shouldContinue","handleAdminDependencies","installIfMissing","compile","configOptions","ignoreDiagnostics","error","message","contextSpinner","console","log","ctx","createBuildContext","contextDuration","adminSpinner","writeStaticClientFiles","bundler","build","buildWebpack","buildVite","adminDuration","on","worker","Error","String","process","exit","debug","send","fork","isWorker","loadStrapiSpinner","strapi","createStrapi","appDir","autoReload","serveAdminPanel","bundleWatcher","strapiInstance","load","generatingTsSpinner","compilingTsSpinner","watcherStarted","ensureWatcher","startWatcher","watch","watchWebpack","watchVite","loadStrapiDuration","get","generators","generate","pwd","rootDir","silent","artifacts","contentTypes","components","compilingDuration","isSpinning","restart","reload","isWatching","isReloading","watcher","igno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,GAAAA;AACVyD,QAAAA,cAAAA,CAAe5B,GAAG,CAAC+D,IAAI,CAAC,CAAC,cAAc,EAAE5F,IAAAA,CAAAA,CAAM,CAAA;AAC/C+E,QAAAA,OAAAA,EAAAA;IACF,CAAA,CAAA,CACCvC,EAAE,CAAC,QAAA,EAAU,CAACxC,IAAAA,GAAAA;AACbyD,QAAAA,cAAAA,CAAe5B,GAAG,CAAC+D,IAAI,CAAC,CAAC,cAAc,EAAE5F,IAAAA,CAAAA,CAAM,CAAA;AAC/C+E,QAAAA,OAAAA,EAAAA;IACF,CAAA,CAAA,CACCvC,EAAE,CAAC,QAAA,EAAU,CAACxC,IAAAA,GAAAA;AACbyD,QAAAA,cAAAA,CAAe5B,GAAG,CAAC+D,IAAI,CAAC,CAAC,cAAc,EAAE5F,IAAAA,CAAAA,CAAM,CAAA;AAC/C+E,QAAAA,OAAAA,EAAAA;AACF,IAAA,CAAA,CAAA;IAEFnC,OAAAA,CAAQJ,EAAE,CAAC,SAAA,EAAW,OAAOd,OAAAA,GAAAA;QAC3B,OAAQA,OAAAA;YACN,KAAK,MAAA;AAAQ,gBAAA;AACXjD,oBAAAA,MAAAA,CAAOqE,KAAK,CACV,2GAAA,CAAA;AAEF,oBAAA,MAAMqC,QAAQU,KAAK,EAAA;AAEnB,oBAAA,MAAMpC,eAAeqC,OAAO,EAAA;AAE5B,oBAAA,IAAItC,aAAAA,EAAe;AACjBA,wBAAAA,aAAAA,CAAcqC,KAAK,EAAA;AACrB,oBAAA;AACAjD,oBAAAA,OAAAA,CAAQG,IAAI,GAAG,QAAA,CAAA;AACf,oBAAA;AACF,gBAAA;AAGF;AACF,IAAA,CAAA,CAAA;AACF;;;;"}
|
|
1
|
+
{"version":3,"file":"develop.js","sources":["../../../src/node/develop.ts"],"sourcesContent":["import fs from 'node:fs/promises';\nimport path from 'node:path';\nimport cluster from 'node:cluster';\n\nimport type chokidarType from 'chokidar';\nimport type { createStrapi as CreateStrapi } from '@strapi/core';\nimport type { CLIContext } from '../cli/types';\nimport { handleAdminDependencies } from './core/ensure-admin-dependencies';\nimport { getTimer, prettyTime, type TimeMeasurer } from './core/timer';\nimport type { WebpackWatcher } from './webpack/watch';\nimport type { ViteWatcher } from './vite/watch';\nimport type { Logger } from '../cli/utils/logger';\n\n// Lazy: worker-only deps; primary cluster process should not pay for them\nconst lazy = <T>(spec: string): (() => T) => {\n let cached: T | undefined;\n return (): T => {\n if (cached === undefined) {\n // eslint-disable-next-line @typescript-eslint/no-var-requires\n cached = require(spec);\n }\n return cached as T;\n };\n};\nconst tsUtils = lazy<typeof import('@strapi/typescript-utils')>('@strapi/typescript-utils');\nconst utils = lazy<typeof import('@strapi/utils')>('@strapi/utils');\nconst chokidar = lazy<typeof chokidarType>('chokidar');\nconst core = lazy<typeof import('@strapi/core')>('@strapi/core');\nconst buildCtx = lazy<typeof import('./create-build-context')>('./create-build-context');\nconst staticFs = lazy<typeof import('./staticFiles')>('./staticFiles');\n\ninterface DevelopOptions extends CLIContext {\n /**\n * Which bundler to use for building.\n *\n * @default webpack\n */\n bundler?: 'webpack' | 'vite';\n polling?: boolean;\n open?: boolean;\n watchAdmin?: boolean;\n buildAdmin?: boolean;\n /**\n * Auto-install missing admin dependencies\n *\n * @default true\n */\n installDeps?: boolean;\n}\n\n// This method removes all non-admin build files from the dist directory\nconst cleanupDistDirectory = async ({\n tsconfig,\n logger,\n timer,\n}: Pick<DevelopOptions, 'tsconfig' | 'logger'> & { timer: TimeMeasurer }) => {\n const distDir = tsconfig?.config?.options?.outDir;\n\n if (\n !distDir || // we don't have a dist dir\n (await fs\n .access(distDir)\n .then(() => false)\n .catch(() => true)) // it doesn't exist -- if it does but no access, that will be caught later\n ) {\n return;\n }\n\n const timerName = `cleaningDist${Date.now()}`;\n timer.start(timerName);\n const cleaningSpinner = logger.spinner(`Cleaning dist dir ${distDir}`).start();\n\n try {\n const dirContent = await fs.readdir(distDir);\n const validFilenames = dirContent\n // Ignore the admin build folder and the TypeScript incremental cache\n .filter((filename) => filename !== 'build' && !filename.endsWith('.tsbuildinfo'));\n for (const filename of validFilenames) {\n await fs.rm(path.resolve(distDir, filename), { recursive: true });\n }\n } catch (err: unknown) {\n const generatingDuration = timer.end(timerName);\n cleaningSpinner.text = `Error cleaning dist dir: ${err} (${prettyTime(generatingDuration)})`;\n cleaningSpinner?.fail();\n return;\n }\n\n const generatingDuration = timer.end(timerName);\n cleaningSpinner.text = `Cleaning dist dir (${prettyTime(generatingDuration)})`;\n cleaningSpinner?.succeed();\n};\n\nconst develop = async ({\n cwd,\n polling,\n logger,\n tsconfig,\n watchAdmin,\n buildAdmin,\n installDeps = true,\n ...options\n}: DevelopOptions) => {\n const timer = getTimer();\n\n if (cluster.isPrimary) {\n const shouldContinue = await handleAdminDependencies({\n cwd,\n logger,\n installIfMissing: installDeps,\n });\n\n if (!shouldContinue) {\n return;\n }\n\n if (tsconfig?.config) {\n // Build without diagnostics in case schemas have changed\n await cleanupDistDirectory({ tsconfig, logger, timer });\n try {\n await tsUtils().compile(cwd, { configOptions: { ignoreDiagnostics: true } });\n } catch (err: unknown) {\n logger.error(`Error during initial TypeScript compilation: ${(err as Error).message}`);\n // We don't return here because we want to attempt to start the server even if the initial compilation fails, as it can be fixed while the server is running\n }\n }\n\n /**\n * IF we're not watching the admin we're going to build it, this makes\n * sure that at least the admin is built for users & they can interact\n * with the application.\n */\n if (!watchAdmin && buildAdmin) {\n timer.start('createBuildContext');\n const contextSpinner = logger.spinner(`Building build context`).start();\n console.log('');\n\n const ctx = await buildCtx().createBuildContext({\n cwd,\n logger,\n tsconfig,\n options,\n });\n const contextDuration = timer.end('createBuildContext');\n contextSpinner.text = `Building build context (${prettyTime(contextDuration)})`;\n contextSpinner.succeed();\n\n timer.start('creatingAdmin');\n const adminSpinner = logger.spinner(`Creating admin`).start();\n\n await staticFs().writeStaticClientFiles(ctx);\n\n if (ctx.bundler === 'webpack') {\n const { build: buildWebpack } = await import('./webpack/build');\n await buildWebpack(ctx);\n } else if (ctx.bundler === 'vite') {\n const { build: buildVite } = await import('./vite/build');\n await buildVite(ctx);\n }\n\n const adminDuration = timer.end('creatingAdmin');\n adminSpinner.text = `Creating admin (${prettyTime(adminDuration)})`;\n adminSpinner.succeed();\n }\n\n cluster.on('message', async (worker, message) => {\n switch (message) {\n case 'reload': {\n if (tsconfig?.config) {\n try {\n // Build without diagnostics in case schemas have changed\n await cleanupDistDirectory({ tsconfig, logger, timer });\n await tsUtils().compile(cwd, { configOptions: { ignoreDiagnostics: true } });\n } catch (err: unknown) {\n const message = err instanceof Error ? err.message : String(err);\n logger.error(`Error during TypeScript compilation on reload: ${message}`);\n process.exit(1);\n }\n }\n logger.debug('cluster has the reload message, sending the worker kill message');\n worker.send('kill');\n break;\n }\n case 'killed': {\n logger.debug('cluster has the killed message, forking the cluster');\n cluster.fork();\n break;\n }\n case 'stop': {\n process.exit(1);\n break;\n }\n default:\n break;\n }\n });\n\n cluster.fork();\n }\n\n if (cluster.isWorker) {\n timer.start('loadStrapi');\n const loadStrapiSpinner = logger.spinner(`Loading Strapi`).start();\n\n const strapi = core().createStrapi({\n appDir: cwd,\n distDir: tsconfig?.config.options.outDir ?? '',\n autoReload: true,\n serveAdminPanel: !watchAdmin,\n });\n\n /**\n * If we're watching the admin panel then we're going to attach the watcher\n * as a strapi middleware.\n */\n let bundleWatcher: WebpackWatcher | ViteWatcher | undefined;\n\n const strapiInstance = await strapi.load();\n\n const contextSpinner = logger.spinner(`Building build context`);\n const adminSpinner = logger.spinner(`Creating admin`);\n const generatingTsSpinner = logger.spinner(`Generating types`);\n const compilingTsSpinner = logger.spinner(`Compiling TS`);\n\n let watcherStarted = false;\n const ensureWatcher = () => {\n if (!watcherStarted) {\n watcherStarted = true;\n startWatcher(strapiInstance, cwd, polling ?? false, logger, bundleWatcher);\n }\n };\n\n try {\n if (watchAdmin) {\n timer.start('createBuildContext');\n contextSpinner.start();\n\n const ctx = await buildCtx().createBuildContext({\n cwd,\n logger,\n strapi,\n tsconfig,\n options,\n });\n const contextDuration = timer.end('createBuildContext');\n contextSpinner.text = `Building build context (${prettyTime(contextDuration)})`;\n contextSpinner.succeed();\n\n timer.start('creatingAdmin');\n adminSpinner.start();\n\n await staticFs().writeStaticClientFiles(ctx);\n\n if (ctx.bundler === 'webpack') {\n const { watch: watchWebpack } = await import('./webpack/watch');\n bundleWatcher = await watchWebpack(ctx);\n } else if (ctx.bundler === 'vite') {\n const { watch: watchVite } = await import('./vite/watch');\n bundleWatcher = await watchVite(ctx);\n }\n\n const adminDuration = timer.end('creatingAdmin');\n adminSpinner.text = `Creating admin (${prettyTime(adminDuration)})`;\n adminSpinner.succeed();\n }\n\n const loadStrapiDuration = timer.end('loadStrapi');\n loadStrapiSpinner.text = `Loading Strapi (${prettyTime(loadStrapiDuration)})`;\n loadStrapiSpinner.succeed();\n\n // For TS projects, type generation is a requirement for the develop command so that the server can restart\n // For JS projects, we respect the experimental autogenerate setting\n if (tsconfig?.config || strapi.config.get('typescript.autogenerate') !== false) {\n timer.start('generatingTS');\n generatingTsSpinner.start();\n\n await tsUtils().generators.generate({\n strapi: strapiInstance,\n pwd: cwd,\n rootDir: undefined,\n logger: { silent: true, debug: false },\n artifacts: { contentTypes: true, components: true },\n });\n\n const generatingDuration = timer.end('generatingTS');\n generatingTsSpinner.text = `Generating types (${prettyTime(generatingDuration)})`;\n generatingTsSpinner.succeed();\n }\n\n if (tsconfig?.config) {\n timer.start('compilingTS');\n compilingTsSpinner.start();\n\n await cleanupDistDirectory({ tsconfig, logger, timer });\n await tsUtils().compile(cwd, { configOptions: { ignoreDiagnostics: false } });\n\n const compilingDuration = timer.end('compilingTS');\n compilingTsSpinner.text = `Compiling TS (${prettyTime(compilingDuration)})`;\n compilingTsSpinner.succeed();\n }\n\n ensureWatcher();\n\n strapiInstance.start();\n } catch (err: unknown) {\n const message = err instanceof Error ? err.message : String(err);\n logger.error(`Error during development: ${message}`);\n\n if (loadStrapiSpinner.isSpinning) {\n loadStrapiSpinner.fail();\n }\n // Fail any spinners that were left running.\n if (contextSpinner.isSpinning) {\n contextSpinner.fail();\n }\n if (compilingTsSpinner.isSpinning) {\n compilingTsSpinner.fail();\n }\n if (adminSpinner.isSpinning) {\n adminSpinner.fail();\n }\n if (generatingTsSpinner.isSpinning) {\n generatingTsSpinner.fail();\n }\n\n ensureWatcher();\n }\n }\n};\n\nfunction startWatcher(\n strapiInstance: Awaited<ReturnType<typeof CreateStrapi>>,\n cwd: string,\n polling: boolean,\n logger: Logger,\n bundleWatcher?: WebpackWatcher | ViteWatcher\n) {\n const restart = async () => {\n if (strapiInstance.reload.isWatching && !strapiInstance.reload.isReloading) {\n strapiInstance.reload.isReloading = true;\n strapiInstance.reload();\n }\n };\n\n const watcher = chokidar()\n .watch(cwd, {\n ignoreInitial: true,\n usePolling: polling,\n ignored: [\n /(^|[/\\\\])\\../, // dot files\n /tmp/,\n '**/src/admin/**',\n '**/src/plugins/**/admin/**',\n '**/dist/src/plugins/test/admin/**',\n '**/documentation',\n '**/documentation/**',\n '**/node_modules',\n '**/node_modules/**',\n '**/plugins.json',\n '**/build',\n '**/build/**',\n '**/log',\n '**/log/**',\n '**/logs',\n '**/logs/**',\n '**/*.log',\n '**/index.html',\n '**/public',\n '**/public/**',\n strapiInstance.dirs.static.public,\n utils().strings.joinBy('/', strapiInstance.dirs.static.public, '**'),\n '**/*.db*',\n '**/exports/**',\n '**/dist/**',\n '**/*.d.ts',\n '**/.yalc/**',\n '**/yalc.lock',\n // TODO v6: watch only src folder by default, and flip this to watchIncludeFiles\n ...strapiInstance.config.get('admin.watchIgnoreFiles', []),\n ],\n })\n .on('add', (path) => {\n strapiInstance.log.info(`File created: ${path}`);\n restart();\n })\n .on('change', (path) => {\n strapiInstance.log.info(`File changed: ${path}`);\n restart();\n })\n .on('unlink', (path) => {\n strapiInstance.log.info(`File deleted: ${path}`);\n restart();\n });\n\n process.on('message', async (message) => {\n switch (message) {\n case 'kill': {\n logger.debug(\n 'child process has the kill message, destroying the strapi instance and sending the killed process message'\n );\n await watcher.close();\n\n await strapiInstance.destroy();\n\n if (bundleWatcher) {\n bundleWatcher.close();\n }\n process.send?.('killed');\n break;\n }\n default:\n break;\n }\n });\n}\n\nexport { develop };\nexport type { DevelopOptions };\n"],"names":["lazy","spec","cached","undefined","require","tsUtils","utils","chokidar","core","buildCtx","staticFs","cleanupDistDirectory","tsconfig","logger","timer","distDir","config","options","outDir","fs","access","then","catch","timerName","Date","now","start","cleaningSpinner","spinner","dirContent","readdir","validFilenames","filter","filename","endsWith","rm","path","resolve","recursive","err","generatingDuration","end","text","prettyTime","fail","succeed","develop","cwd","polling","watchAdmin","buildAdmin","installDeps","getTimer","cluster","isPrimary","shouldContinue","handleAdminDependencies","installIfMissing","compile","configOptions","ignoreDiagnostics","error","message","contextSpinner","console","log","ctx","createBuildContext","contextDuration","adminSpinner","writeStaticClientFiles","bundler","build","buildWebpack","buildVite","adminDuration","on","worker","Error","String","process","exit","debug","send","fork","isWorker","loadStrapiSpinner","strapi","createStrapi","appDir","autoReload","serveAdminPanel","bundleWatcher","strapiInstance","load","generatingTsSpinner","compilingTsSpinner","watcherStarted","ensureWatcher","startWatcher","watch","watchWebpack","watchVite","loadStrapiDuration","get","generators","generate","pwd","rootDir","silent","artifacts","contentTypes","components","compilingDuration","isSpinning","restart","reload","isWatching","isReloading","watcher","ignoreInitial","usePolling","ignored","dirs","static","public","strings","joinBy","info","close","destroy"],"mappings":";;;;;;;;;;;;;;AAaA;AACA,MAAMA,OAAO,CAAIC,IAAAA,GAAAA;IACf,IAAIC,MAAAA;IACJ,OAAO,IAAA;AACL,QAAA,IAAIA,WAAWC,SAAAA,EAAW;;AAExBD,YAAAA,MAAAA,GAASE,OAAAA,CAAQH,IAAAA,CAAAA;AACnB,QAAA;QACA,OAAOC,MAAAA;AACT,IAAA,CAAA;AACF,CAAA;AACA,MAAMG,UAAUL,IAAAA,CAAgD,0BAAA,CAAA;AAChE,MAAMM,QAAQN,IAAAA,CAAqC,eAAA,CAAA;AACnD,MAAMO,WAAW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,IAAAA,GAAAA;AACbyD,QAAAA,cAAAA,CAAe5B,GAAG,CAAC+D,IAAI,CAAC,CAAC,cAAc,EAAE5F,IAAAA,CAAAA,CAAM,CAAA;AAC/C+E,QAAAA,OAAAA,EAAAA;AACF,IAAA,CAAA,CAAA;IAEFnC,OAAAA,CAAQJ,EAAE,CAAC,SAAA,EAAW,OAAOd,OAAAA,GAAAA;QAC3B,OAAQA,OAAAA;YACN,KAAK,MAAA;AAAQ,gBAAA;AACXjD,oBAAAA,MAAAA,CAAOqE,KAAK,CACV,2GAAA,CAAA;AAEF,oBAAA,MAAMqC,QAAQU,KAAK,EAAA;AAEnB,oBAAA,MAAMpC,eAAeqC,OAAO,EAAA;AAE5B,oBAAA,IAAItC,aAAAA,EAAe;AACjBA,wBAAAA,aAAAA,CAAcqC,KAAK,EAAA;AACrB,oBAAA;AACAjD,oBAAAA,OAAAA,CAAQG,IAAI,GAAG,QAAA,CAAA;AACf,oBAAA;AACF,gBAAA;AAGF;AACF,IAAA,CAAA,CAAA;AACF;;;;"}
|
|
@@ -7,10 +7,16 @@ var react = require('react');
|
|
|
7
7
|
var server = require('react-dom/server');
|
|
8
8
|
var _internal = require('@strapi/admin/_internal');
|
|
9
9
|
|
|
10
|
+
function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
|
|
11
|
+
|
|
12
|
+
var fs__default = /*#__PURE__*/_interopDefault(fs);
|
|
13
|
+
var path__default = /*#__PURE__*/_interopDefault(path);
|
|
14
|
+
var outdent__default = /*#__PURE__*/_interopDefault(outdent);
|
|
15
|
+
|
|
10
16
|
const getEntryModule = (ctx)=>{
|
|
11
17
|
const pluginsObject = ctx.plugins.map(({ name, importName })=>`'${name}': ${importName}`).join(',\n');
|
|
12
18
|
const pluginsImport = ctx.plugins.map(({ importName, modulePath })=>`import ${importName} from '${modulePath}';`).join('\n');
|
|
13
|
-
return
|
|
19
|
+
return outdent__default.default`
|
|
14
20
|
/**
|
|
15
21
|
* This file was automatically generated by Strapi.
|
|
16
22
|
* Any modifications made will be discarded.
|
|
@@ -37,7 +43,7 @@ const getEntryModule = (ctx)=>{
|
|
|
37
43
|
*/ const getDocumentHTML = ({ logger, props = {} })=>{
|
|
38
44
|
const result = server.renderToStaticMarkup(react.createElement(_internal.DefaultDocument, props));
|
|
39
45
|
logger.debug('Rendered the HTML');
|
|
40
|
-
return
|
|
46
|
+
return outdent__default.default`<!DOCTYPE html>${result}`;
|
|
41
47
|
};
|
|
42
48
|
const AUTO_GENERATED_WARNING = `
|
|
43
49
|
This file was automatically generated by Strapi.
|
|
@@ -56,7 +62,7 @@ const writeStaticClientFiles = async (ctx)=>{
|
|
|
56
62
|
* We then use the function we need to "createAdmin" as well as generate the Document index.html as well.
|
|
57
63
|
*
|
|
58
64
|
* All this links together an imaginary "src/index" that then allows vite to correctly build the admin panel.
|
|
59
|
-
*/ await
|
|
65
|
+
*/ await fs__default.default.mkdir(ctx.runtimeDir, {
|
|
60
66
|
recursive: true
|
|
61
67
|
});
|
|
62
68
|
ctx.logger.debug('Created the runtime directory');
|
|
@@ -66,11 +72,11 @@ const writeStaticClientFiles = async (ctx)=>{
|
|
|
66
72
|
entryPath: `/${ctx.entry}`
|
|
67
73
|
} : undefined
|
|
68
74
|
}));
|
|
69
|
-
await
|
|
75
|
+
await fs__default.default.writeFile(path__default.default.join(ctx.runtimeDir, 'index.html'), await prettier.format(indexHtml, {
|
|
70
76
|
parser: 'html'
|
|
71
77
|
}));
|
|
72
78
|
ctx.logger.debug('Wrote the index.html file');
|
|
73
|
-
await
|
|
79
|
+
await fs__default.default.writeFile(path__default.default.join(ctx.runtimeDir, 'app.js'), await prettier.format(getEntryModule(ctx), {
|
|
74
80
|
parser: 'babel'
|
|
75
81
|
}));
|
|
76
82
|
ctx.logger.debug('Wrote the app.js file');
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"staticFiles.js","sources":["../../../src/node/staticFiles.ts"],"sourcesContent":["import fs from 'node:fs/promises';\nimport path from 'node:path';\nimport outdent from 'outdent';\nimport { createElement } from 'react';\nimport { renderToStaticMarkup } from 'react-dom/server';\nimport { DefaultDocument } from '@strapi/admin/_internal';\n\nimport type { BuildContext } from './create-build-context';\n\nconst getEntryModule = (ctx: BuildContext): string => {\n const pluginsObject = ctx.plugins\n .map(({ name, importName }) => `'${name}': ${importName}`)\n .join(',\\n');\n\n const pluginsImport = ctx.plugins\n .map(({ importName, modulePath }) => `import ${importName} from '${modulePath}';`)\n .join('\\n');\n\n return outdent`\n /**\n * This file was automatically generated by Strapi.\n * Any modifications made will be discarded.\n */\n ${pluginsImport}\n import { renderAdmin } from \"@strapi/strapi/admin\"\n\n ${\n ctx.customisations?.modulePath\n ? `import customisations from '${ctx.customisations.modulePath}'`\n : ''\n }\n\n renderAdmin(\n document.getElementById(\"strapi\"),\n {\n ${ctx.customisations?.modulePath ? 'customisations,' : ''}\n ${ctx.features ? `features: ${JSON.stringify(ctx.features)},` : ''}\n plugins: {\n ${pluginsObject}\n }\n })\n `;\n};\n\ninterface GetDocumentHTMLArgs extends Pick<BuildContext, 'logger'> {\n props?: {\n entryPath?: string;\n };\n}\n\n/**\n * TODO: Here in the future we could add the ability\n * to load a user's Document component?\n */\nconst getDocumentHTML = ({ logger, props = {} }: GetDocumentHTMLArgs) => {\n const result = renderToStaticMarkup(createElement(DefaultDocument, props));\n logger.debug('Rendered the HTML');\n\n return outdent`<!DOCTYPE html>${result}`;\n};\n\nconst AUTO_GENERATED_WARNING = `\nThis file was automatically generated by Strapi.\nAny modifications made will be discarded.\n`.trim();\n\n/**\n * Because we now auto-generate the index.html file,\n * we should be clear that people _should not_ modify it.\n *\n * @internal\n */\nconst decorateHTMLWithAutoGeneratedWarning = (htmlTemplate: string): string =>\n htmlTemplate.replace(/<head/, `\\n<!--\\n${AUTO_GENERATED_WARNING}\\n-->\\n<head`);\n\nconst writeStaticClientFiles = async (ctx: BuildContext) => {\n const prettier = await import('prettier'); // ESM-only\n\n /**\n * For everything to work effectively we create a client folder in `.strapi` at the cwd level.\n * We then use the function we need to \"createAdmin\" as well as generate the Document index.html as well.\n *\n * All this links together an imaginary \"src/index\" that then allows vite to correctly build the admin panel.\n */\n\n await fs.mkdir(ctx.runtimeDir, { recursive: true });\n ctx.logger.debug('Created the runtime directory');\n\n const indexHtml = decorateHTMLWithAutoGeneratedWarning(\n await getDocumentHTML({\n logger: ctx.logger,\n props:\n ctx.bundler === 'vite'\n ? {\n entryPath: `/${ctx.entry}`,\n }\n : undefined,\n })\n );\n\n await fs.writeFile(\n path.join(ctx.runtimeDir, 'index.html'),\n await prettier.format(indexHtml, {\n parser: 'html',\n })\n );\n ctx.logger.debug('Wrote the index.html file');\n await fs.writeFile(\n path.join(ctx.runtimeDir, 'app.js'),\n await prettier.format(getEntryModule(ctx), {\n parser: 'babel',\n })\n );\n ctx.logger.debug('Wrote the app.js file');\n};\n\nexport { writeStaticClientFiles, getDocumentHTML };\n"],"names":["getEntryModule","ctx","pluginsObject","plugins","map","name","importName","join","pluginsImport","modulePath","outdent","customisations","features","JSON","stringify","getDocumentHTML","logger","props","result","renderToStaticMarkup","createElement","DefaultDocument","debug","AUTO_GENERATED_WARNING","trim","decorateHTMLWithAutoGeneratedWarning","htmlTemplate","replace","writeStaticClientFiles","prettier","fs","mkdir","runtimeDir","recursive","indexHtml","bundler","entryPath","entry","undefined","writeFile","path","format","parser"],"mappings":"
|
|
1
|
+
{"version":3,"file":"staticFiles.js","sources":["../../../src/node/staticFiles.ts"],"sourcesContent":["import fs from 'node:fs/promises';\nimport path from 'node:path';\nimport outdent from 'outdent';\nimport { createElement } from 'react';\nimport { renderToStaticMarkup } from 'react-dom/server';\nimport { DefaultDocument } from '@strapi/admin/_internal';\n\nimport type { BuildContext } from './create-build-context';\n\nconst getEntryModule = (ctx: BuildContext): string => {\n const pluginsObject = ctx.plugins\n .map(({ name, importName }) => `'${name}': ${importName}`)\n .join(',\\n');\n\n const pluginsImport = ctx.plugins\n .map(({ importName, modulePath }) => `import ${importName} from '${modulePath}';`)\n .join('\\n');\n\n return outdent`\n /**\n * This file was automatically generated by Strapi.\n * Any modifications made will be discarded.\n */\n ${pluginsImport}\n import { renderAdmin } from \"@strapi/strapi/admin\"\n\n ${\n ctx.customisations?.modulePath\n ? `import customisations from '${ctx.customisations.modulePath}'`\n : ''\n }\n\n renderAdmin(\n document.getElementById(\"strapi\"),\n {\n ${ctx.customisations?.modulePath ? 'customisations,' : ''}\n ${ctx.features ? `features: ${JSON.stringify(ctx.features)},` : ''}\n plugins: {\n ${pluginsObject}\n }\n })\n `;\n};\n\ninterface GetDocumentHTMLArgs extends Pick<BuildContext, 'logger'> {\n props?: {\n entryPath?: string;\n };\n}\n\n/**\n * TODO: Here in the future we could add the ability\n * to load a user's Document component?\n */\nconst getDocumentHTML = ({ logger, props = {} }: GetDocumentHTMLArgs) => {\n const result = renderToStaticMarkup(createElement(DefaultDocument, props));\n logger.debug('Rendered the HTML');\n\n return outdent`<!DOCTYPE html>${result}`;\n};\n\nconst AUTO_GENERATED_WARNING = `\nThis file was automatically generated by Strapi.\nAny modifications made will be discarded.\n`.trim();\n\n/**\n * Because we now auto-generate the index.html file,\n * we should be clear that people _should not_ modify it.\n *\n * @internal\n */\nconst decorateHTMLWithAutoGeneratedWarning = (htmlTemplate: string): string =>\n htmlTemplate.replace(/<head/, `\\n<!--\\n${AUTO_GENERATED_WARNING}\\n-->\\n<head`);\n\nconst writeStaticClientFiles = async (ctx: BuildContext) => {\n const prettier = await import('prettier'); // ESM-only\n\n /**\n * For everything to work effectively we create a client folder in `.strapi` at the cwd level.\n * We then use the function we need to \"createAdmin\" as well as generate the Document index.html as well.\n *\n * All this links together an imaginary \"src/index\" that then allows vite to correctly build the admin panel.\n */\n\n await fs.mkdir(ctx.runtimeDir, { recursive: true });\n ctx.logger.debug('Created the runtime directory');\n\n const indexHtml = decorateHTMLWithAutoGeneratedWarning(\n await getDocumentHTML({\n logger: ctx.logger,\n props:\n ctx.bundler === 'vite'\n ? {\n entryPath: `/${ctx.entry}`,\n }\n : undefined,\n })\n );\n\n await fs.writeFile(\n path.join(ctx.runtimeDir, 'index.html'),\n await prettier.format(indexHtml, {\n parser: 'html',\n })\n );\n ctx.logger.debug('Wrote the index.html file');\n await fs.writeFile(\n path.join(ctx.runtimeDir, 'app.js'),\n await prettier.format(getEntryModule(ctx), {\n parser: 'babel',\n })\n );\n ctx.logger.debug('Wrote the app.js file');\n};\n\nexport { writeStaticClientFiles, getDocumentHTML };\n"],"names":["getEntryModule","ctx","pluginsObject","plugins","map","name","importName","join","pluginsImport","modulePath","outdent","customisations","features","JSON","stringify","getDocumentHTML","logger","props","result","renderToStaticMarkup","createElement","DefaultDocument","debug","AUTO_GENERATED_WARNING","trim","decorateHTMLWithAutoGeneratedWarning","htmlTemplate","replace","writeStaticClientFiles","prettier","fs","mkdir","runtimeDir","recursive","indexHtml","bundler","entryPath","entry","undefined","writeFile","path","format","parser"],"mappings":";;;;;;;;;;;;;;;AASA,MAAMA,iBAAiB,CAACC,GAAAA,GAAAA;IACtB,MAAMC,aAAAA,GAAgBD,IAAIE,OAAO,CAC9BC,GAAG,CAAC,CAAC,EAAEC,IAAI,EAAEC,UAAU,EAAE,GAAK,CAAC,CAAC,EAAED,IAAAA,CAAK,GAAG,EAAEC,UAAAA,CAAAA,CAAY,CAAA,CACxDC,IAAI,CAAC,KAAA,CAAA;IAER,MAAMC,aAAAA,GAAgBP,GAAAA,CAAIE,OAAO,CAC9BC,GAAG,CAAC,CAAC,EAAEE,UAAU,EAAEG,UAAU,EAAE,GAAK,CAAC,OAAO,EAAEH,UAAAA,CAAW,OAAO,EAAEG,WAAW,EAAE,CAAC,CAAA,CAChFF,IAAI,CAAC,IAAA,CAAA;AAER,IAAA,OAAOG,wBAAO;;;;;AAKR,QAAA,EAAEF,aAAAA;;;AAGF,QAAA,EACEP,GAAAA,CAAIU,cAAc,EAAEF,UAAAA,GAChB,CAAC,4BAA4B,EAAER,GAAAA,CAAIU,cAAc,CAACF,UAAU,CAAC,CAAC,CAAC,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kC,OAAO,KAAK,MAAA,GACZ;AACEC,YAAAA,SAAAA,EAAW,CAAC,CAAC,EAAEnC,GAAAA,CAAIoC,KAAK,CAAA;SAC1B,GACAC;AACR,KAAA,CAAA,CAAA;AAGF,IAAA,MAAMR,mBAAAA,CAAGS,SAAS,CAChBC,qBAAAA,CAAKjC,IAAI,CAACN,GAAAA,CAAI+B,UAAU,EAAE,YAAA,CAAA,EAC1B,MAAMH,QAAAA,CAASY,MAAM,CAACP,SAAAA,EAAW;QAC/BQ,MAAAA,EAAQ;AACV,KAAA,CAAA,CAAA;IAEFzC,GAAAA,CAAIe,MAAM,CAACM,KAAK,CAAC,2BAAA,CAAA;AACjB,IAAA,MAAMQ,mBAAAA,CAAGS,SAAS,CAChBC,qBAAAA,CAAKjC,IAAI,CAACN,GAAAA,CAAI+B,UAAU,EAAE,WAC1B,MAAMH,QAAAA,CAASY,MAAM,CAACzC,eAAeC,GAAAA,CAAAA,EAAM;QACzCyC,MAAAA,EAAQ;AACV,KAAA,CAAA,CAAA;IAEFzC,GAAAA,CAAIe,MAAM,CAACM,KAAK,CAAC,uBAAA,CAAA;AACnB;;;;;"}
|
|
@@ -8,6 +8,10 @@ var monorepo = require('../core/monorepo.js');
|
|
|
8
8
|
var aliases = require('../core/aliases.js');
|
|
9
9
|
var plugins = require('./plugins.js');
|
|
10
10
|
|
|
11
|
+
function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
|
|
12
|
+
|
|
13
|
+
var react__default = /*#__PURE__*/_interopDefault(react);
|
|
14
|
+
|
|
11
15
|
const resolveBaseConfig = async (ctx)=>{
|
|
12
16
|
const { default: browserslistToEsbuild } = await import('browserslist-to-esbuild');
|
|
13
17
|
const target = browserslistToEsbuild(ctx.target);
|
|
@@ -151,7 +155,7 @@ const resolveBaseConfig = async (ctx)=>{
|
|
|
151
155
|
}
|
|
152
156
|
},
|
|
153
157
|
plugins: [
|
|
154
|
-
|
|
158
|
+
react__default.default(),
|
|
155
159
|
plugins.buildFilesPlugin(ctx)
|
|
156
160
|
]
|
|
157
161
|
};
|
|
@@ -193,12 +197,19 @@ const resolveDevelopmentConfig = async (ctx)=>{
|
|
|
193
197
|
},
|
|
194
198
|
server: {
|
|
195
199
|
cors: false,
|
|
200
|
+
/**
|
|
201
|
+
* In middleware mode Strapi forwards the browser Host from reverse proxies (nginx, Traefik).
|
|
202
|
+
* Vite 5+ blocks unknown hosts unless explicitly allowed (#23491).
|
|
203
|
+
*/ allowedHosts: true,
|
|
196
204
|
middlewareMode: true,
|
|
197
205
|
open: ctx.options.open,
|
|
198
206
|
hmr: {
|
|
199
207
|
overlay: false,
|
|
200
|
-
|
|
201
|
-
|
|
208
|
+
/**
|
|
209
|
+
* Use Strapi's http.Server so HMR websockets reuse the app's listen port. A separate listener
|
|
210
|
+
* plus clientPort pushes browsers toward host:5173-style URLs that fail behind proxies that
|
|
211
|
+
* only expose the Strapi server port (#23491, #23008).
|
|
212
|
+
*/ server: ctx.strapi.server.httpServer
|
|
202
213
|
}
|
|
203
214
|
},
|
|
204
215
|
appType: 'custom'
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config.js","sources":["../../../../src/node/vite/config.ts"],"sourcesContent":["import type { InlineConfig, UserConfig } from 'vite';\nimport react from '@vitejs/plugin-react-swc';\n\nimport { getUserConfig } from '../core/config';\nimport { getModulePath } from '../core/resolve-module';\nimport { isDesignSystemLinked } from '../core/linked-packages';\nimport { loadStrapiMonorepo } from '../core/monorepo';\nimport { getMonorepoAliases } from '../core/aliases';\nimport type { BuildContext } from '../create-build-context';\nimport { buildFilesPlugin } from './plugins';\n\nconst resolveBaseConfig = async (ctx: BuildContext): Promise<InlineConfig> => {\n const { default: browserslistToEsbuild } = await import('browserslist-to-esbuild');\n const target = browserslistToEsbuild(ctx.target);\n const isMonorepoExampleApp = (ctx.strapi as any).internal_config?.uuid === 'getstarted';\n const designSystemLinked = isDesignSystemLinked();\n\n return {\n root: ctx.cwd,\n base: ctx.basePath,\n build: {\n emptyOutDir: false, // Rely on CLI to do this\n outDir: ctx.distDir,\n target,\n },\n cacheDir: 'node_modules/.strapi/vite',\n configFile: false,\n define: {\n process: {},\n 'process.env': JSON.stringify(ctx.env),\n },\n envPrefix: 'STRAPI_ADMIN_',\n optimizeDeps: {\n // When design-system is linked (portal:, file:, yarn link), exclude from pre-bundling\n // so changes are reflected without clearing node_modules/.strapi/vite cache\n ...(designSystemLinked && { exclude: ['@strapi/design-system'] }),\n include: [\n // pre-bundle React dependencies to avoid React duplicates,\n // even if React dependencies are not direct dependencies\n // https://react.dev/warnings/invalid-hook-call-warning#duplicate-react\n 'react',\n `react/jsx-runtime`,\n 'react-dom/client',\n 'styled-components',\n 'react-router-dom',\n // Admin + RTK Query share react-redux context; pre-bundle so dev chunks cannot load a\n // second copy (avoids \"could not find react-redux context value\" after upgrades / hoisting).\n 'react-redux',\n '@reduxjs/toolkit',\n // Pre-bundle design-system so plugin custom field chunks (dynamic imports) resolve\n // to the same instance as the main app. Otherwise TooltipProvider/DesignSystemProvider\n // context from the root is not seen by components in plugin chunks.\n // Omit when linked so local changes are picked up (see exclude above)\n ...(!designSystemLinked ? ['@strapi/design-system'] : []),\n '@radix-ui/react-tooltip',\n // Pre-bundle lodash: design-system uses named imports (e.g. assignWith) but lodash\n // is CommonJS-only; pre-bundling converts it to ESM for the browser\n 'lodash',\n // Pre-bundle prismjs so plugin chunks get a valid ESM namespace (prismjs is UMD and can\n // otherwise expose an empty object when bundled, causing \"Prism is not defined\" in admin).\n 'prismjs',\n /**\n * Pre-bundle other dependencies that would otherwise cause a page reload when imported.\n * See \"performance\" section: https://vite.dev/guide/dep-pre-bundling.html#the-why\n * Only include dependencies for our internal example apps, otherwise it will break\n * real user apps that may not have those dependencies.\n */\n ...(isMonorepoExampleApp\n ? [\n '@dnd-kit/core',\n '@dnd-kit/sortable',\n '@dnd-kit/utilities',\n '@dnd-kit/modifiers',\n '@radix-ui/react-toolbar',\n 'codemirror5',\n 'codemirror5/addon/display/placeholder',\n 'date-fns-tz',\n 'date-fns/format',\n 'date-fns/formatISO',\n 'highlight.js',\n 'lodash/capitalize',\n 'lodash/fp',\n 'lodash/groupBy',\n 'lodash/has',\n 'lodash/isNil',\n 'lodash/locale',\n 'lodash/map',\n 'lodash/mapValues',\n 'lodash/pull',\n 'lodash/size',\n 'lodash/sortBy',\n 'lodash/tail',\n 'lodash/toLower',\n 'lodash/toNumber',\n 'lodash/toString',\n 'lodash/truncate',\n 'lodash/uniq',\n 'lodash/upperFirst',\n 'markdown-it',\n 'markdown-it-abbr',\n 'markdown-it-container',\n 'markdown-it-deflist',\n 'markdown-it-emoji',\n 'markdown-it-footnote',\n 'markdown-it-ins',\n 'markdown-it-mark',\n 'markdown-it-sub',\n 'markdown-it-sup',\n 'prismjs/components/*.js',\n 'react-colorful',\n 'react-dnd-html5-backend',\n 'react-window',\n 'semver',\n 'semver/functions/lt',\n 'semver/functions/valid',\n 'slate',\n 'slate-history',\n 'slate-react',\n 'motion',\n ]\n : []),\n ],\n },\n resolve: {\n // https://react.dev/warnings/invalid-hook-call-warning#duplicate-react\n // Include design-system so plugin chunks use the same instance and inherit root context\n dedupe: [\n 'react',\n 'react-dom',\n 'react-router-dom',\n 'styled-components',\n 'react-redux',\n '@reduxjs/toolkit',\n '@strapi/design-system',\n '@radix-ui/react-tooltip',\n 'lodash',\n ],\n // Explicit aliases ensure resolution under pnpm's strict dependency isolation,\n // where packages imported by plugins may not be resolvable from plugin chunks\n alias: {\n react: getModulePath('react'),\n 'react-dom': getModulePath('react-dom'),\n 'react-router-dom': getModulePath('react-router-dom'),\n 'styled-components': getModulePath('styled-components'),\n 'react-redux': getModulePath('react-redux'),\n '@reduxjs/toolkit': getModulePath('@reduxjs/toolkit'),\n '@strapi/design-system': getModulePath('@strapi/design-system'),\n '@radix-ui/react-tooltip': getModulePath('@radix-ui/react-tooltip'),\n lodash: getModulePath('lodash'),\n },\n },\n plugins: [react(), buildFilesPlugin(ctx)],\n };\n};\n\nconst resolveProductionConfig = async (ctx: BuildContext): Promise<InlineConfig> => {\n const {\n options: { minify, sourcemaps },\n } = ctx;\n\n const baseConfig = await resolveBaseConfig(ctx);\n\n return {\n ...baseConfig,\n logLevel: 'silent',\n mode: 'production',\n build: {\n ...baseConfig.build,\n assetsDir: '',\n minify,\n sourcemap: sourcemaps,\n rollupOptions: {\n input: {\n strapi: ctx.entry,\n },\n },\n },\n };\n};\n\nconst resolveDevelopmentConfig = async (ctx: BuildContext): Promise<InlineConfig> => {\n const monorepo = await loadStrapiMonorepo(ctx.cwd);\n const baseConfig = await resolveBaseConfig(ctx);\n\n return {\n ...baseConfig,\n mode: 'development',\n resolve: {\n ...baseConfig.resolve,\n alias: {\n ...baseConfig.resolve?.alias,\n ...getMonorepoAliases({ monorepo }),\n },\n },\n server: {\n cors: false,\n middlewareMode: true,\n open: ctx.options.open,\n hmr: {\n overlay: false,\n server: ctx.options.hmrServer,\n clientPort: ctx.options.hmrClientPort,\n },\n },\n appType: 'custom',\n };\n};\n\nconst USER_CONFIGS = ['vite.config.js', 'vite.config.mjs', 'vite.config.ts', 'vite.config.mts'];\n\ntype UserViteConfig = (config: UserConfig) => UserConfig;\n\nconst mergeConfigWithUserConfig = async (config: InlineConfig, ctx: BuildContext) => {\n const userConfig = await getUserConfig<UserViteConfig>(USER_CONFIGS, ctx);\n\n if (userConfig) {\n return userConfig(config);\n }\n\n return config;\n};\n\nexport { mergeConfigWithUserConfig, resolveProductionConfig, resolveDevelopmentConfig };\n"],"names":["resolveBaseConfig","ctx","default","browserslistToEsbuild","target","isMonorepoExampleApp","strapi","internal_config","uuid","designSystemLinked","isDesignSystemLinked","root","cwd","base","basePath","build","emptyOutDir","outDir","distDir","cacheDir","configFile","define","process","JSON","stringify","env","envPrefix","optimizeDeps","exclude","include","resolve","dedupe","alias","react","getModulePath","lodash","plugins","buildFilesPlugin","resolveProductionConfig","options","minify","sourcemaps","baseConfig","logLevel","mode","assetsDir","sourcemap","rollupOptions","input","entry","resolveDevelopmentConfig","monorepo","loadStrapiMonorepo","getMonorepoAliases","server","cors","middlewareMode","open","hmr","overlay","hmrServer","clientPort","hmrClientPort","appType","USER_CONFIGS","mergeConfigWithUserConfig","config","userConfig","getUserConfig"],"mappings":";;;;;;;;;;AAWA,MAAMA,oBAAoB,OAAOC,GAAAA,GAAAA;AAC/B,IAAA,MAAM,EAAEC,OAAAA,EAASC,qBAAqB,EAAE,GAAG,MAAM,OAAO,yBAAA,CAAA;IACxD,MAAMC,MAAAA,GAASD,qBAAAA,CAAsBF,GAAAA,CAAIG,MAAM,CAAA;AAC/C,IAAA,MAAMC,uBAAuB,GAACJ,CAAIK,MAAM,CAASC,eAAe,EAAEC,IAAAA,KAAS,YAAA;AAC3E,IAAA,MAAMC,kBAAAA,GAAqBC,mCAAAA,EAAAA;IAE3B,OAAO;AACLC,QAAAA,IAAAA,EAAMV,IAAIW,GAAG;AACbC,QAAAA,IAAAA,EAAMZ,IAAIa,QAAQ;QAClBC,KAAAA,EAAO;YACLC,WAAAA,EAAa,KAAA;AACbC,YAAAA,MAAAA,EAAQhB,IAAIiB,OAAO;AACnBd,YAAAA;AACF,SAAA;QACAe,QAAAA,EAAU,2BAAA;QACVC,UAAAA,EAAY,KAAA;QACZC,MAAAA,EAAQ;AACNC,YAAAA,OAAAA,EAAS,EAAC;AACV,YAAA,aAAA,EAAeC,IAAAA,CAAKC,SAAS,CAACvB,GAAAA,CAAIwB,GAAG;AACvC,SAAA;QACAC,SAAAA,EAAW,eAAA;QACXC,YAAAA,EAAc;;;AAGZ,YAAA,GAAIlB,kBAAAA,IAAsB;gBAAEmB,OAAAA,EAAS;AAAC,oBAAA;AAAwB;aAAE;YAChEC,OAAAA,EAAS;;;;AAIP,gBAAA,OAAA;AACA,gBAAA,CAAC,iBAAiB,CAAC;AACnB,gBAAA,kBAAA;AACA,gBAAA,mBAAA;AACA,gBAAA,kBAAA;;;AAGA,gBAAA,aAAA;AACA,gBAAA,kBAAA;;;;;AAKI,gBAAA,GAAA,CAACpB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;;;;"}
|
|
1
|
+
{"version":3,"file":"config.js","sources":["../../../../src/node/vite/config.ts"],"sourcesContent":["import type { InlineConfig, UserConfig } from 'vite';\nimport react from '@vitejs/plugin-react-swc';\n\nimport { getUserConfig } from '../core/config';\nimport { getModulePath } from '../core/resolve-module';\nimport { isDesignSystemLinked } from '../core/linked-packages';\nimport { loadStrapiMonorepo } from '../core/monorepo';\nimport { getMonorepoAliases } from '../core/aliases';\nimport type { BuildContext } from '../create-build-context';\nimport { buildFilesPlugin } from './plugins';\n\nconst resolveBaseConfig = async (ctx: BuildContext): Promise<InlineConfig> => {\n const { default: browserslistToEsbuild } = await import('browserslist-to-esbuild');\n const target = browserslistToEsbuild(ctx.target);\n const isMonorepoExampleApp = (ctx.strapi as any).internal_config?.uuid === 'getstarted';\n const designSystemLinked = isDesignSystemLinked();\n\n return {\n root: ctx.cwd,\n base: ctx.basePath,\n build: {\n emptyOutDir: false, // Rely on CLI to do this\n outDir: ctx.distDir,\n target,\n },\n cacheDir: 'node_modules/.strapi/vite',\n configFile: false,\n define: {\n process: {},\n 'process.env': JSON.stringify(ctx.env),\n },\n envPrefix: 'STRAPI_ADMIN_',\n optimizeDeps: {\n // When design-system is linked (portal:, file:, yarn link), exclude from pre-bundling\n // so changes are reflected without clearing node_modules/.strapi/vite cache\n ...(designSystemLinked && { exclude: ['@strapi/design-system'] }),\n include: [\n // pre-bundle React dependencies to avoid React duplicates,\n // even if React dependencies are not direct dependencies\n // https://react.dev/warnings/invalid-hook-call-warning#duplicate-react\n 'react',\n `react/jsx-runtime`,\n 'react-dom/client',\n 'styled-components',\n 'react-router-dom',\n // Admin + RTK Query share react-redux context; pre-bundle so dev chunks cannot load a\n // second copy (avoids \"could not find react-redux context value\" after upgrades / hoisting).\n 'react-redux',\n '@reduxjs/toolkit',\n // Pre-bundle design-system so plugin custom field chunks (dynamic imports) resolve\n // to the same instance as the main app. Otherwise TooltipProvider/DesignSystemProvider\n // context from the root is not seen by components in plugin chunks.\n // Omit when linked so local changes are picked up (see exclude above)\n ...(!designSystemLinked ? ['@strapi/design-system'] : []),\n '@radix-ui/react-tooltip',\n // Pre-bundle lodash: design-system uses named imports (e.g. assignWith) but lodash\n // is CommonJS-only; pre-bundling converts it to ESM for the browser\n 'lodash',\n // Pre-bundle prismjs so plugin chunks get a valid ESM namespace (prismjs is UMD and can\n // otherwise expose an empty object when bundled, causing \"Prism is not defined\" in admin).\n 'prismjs',\n /**\n * Pre-bundle other dependencies that would otherwise cause a page reload when imported.\n * See \"performance\" section: https://vite.dev/guide/dep-pre-bundling.html#the-why\n * Only include dependencies for our internal example apps, otherwise it will break\n * real user apps that may not have those dependencies.\n */\n ...(isMonorepoExampleApp\n ? [\n '@dnd-kit/core',\n '@dnd-kit/sortable',\n '@dnd-kit/utilities',\n '@dnd-kit/modifiers',\n '@radix-ui/react-toolbar',\n 'codemirror5',\n 'codemirror5/addon/display/placeholder',\n 'date-fns-tz',\n 'date-fns/format',\n 'date-fns/formatISO',\n 'highlight.js',\n 'lodash/capitalize',\n 'lodash/fp',\n 'lodash/groupBy',\n 'lodash/has',\n 'lodash/isNil',\n 'lodash/locale',\n 'lodash/map',\n 'lodash/mapValues',\n 'lodash/pull',\n 'lodash/size',\n 'lodash/sortBy',\n 'lodash/tail',\n 'lodash/toLower',\n 'lodash/toNumber',\n 'lodash/toString',\n 'lodash/truncate',\n 'lodash/uniq',\n 'lodash/upperFirst',\n 'markdown-it',\n 'markdown-it-abbr',\n 'markdown-it-container',\n 'markdown-it-deflist',\n 'markdown-it-emoji',\n 'markdown-it-footnote',\n 'markdown-it-ins',\n 'markdown-it-mark',\n 'markdown-it-sub',\n 'markdown-it-sup',\n 'prismjs/components/*.js',\n 'react-colorful',\n 'react-dnd-html5-backend',\n 'react-window',\n 'semver',\n 'semver/functions/lt',\n 'semver/functions/valid',\n 'slate',\n 'slate-history',\n 'slate-react',\n 'motion',\n ]\n : []),\n ],\n },\n resolve: {\n // https://react.dev/warnings/invalid-hook-call-warning#duplicate-react\n // Include design-system so plugin chunks use the same instance and inherit root context\n dedupe: [\n 'react',\n 'react-dom',\n 'react-router-dom',\n 'styled-components',\n 'react-redux',\n '@reduxjs/toolkit',\n '@strapi/design-system',\n '@radix-ui/react-tooltip',\n 'lodash',\n ],\n // Explicit aliases ensure resolution under pnpm's strict dependency isolation,\n // where packages imported by plugins may not be resolvable from plugin chunks\n alias: {\n react: getModulePath('react'),\n 'react-dom': getModulePath('react-dom'),\n 'react-router-dom': getModulePath('react-router-dom'),\n 'styled-components': getModulePath('styled-components'),\n 'react-redux': getModulePath('react-redux'),\n '@reduxjs/toolkit': getModulePath('@reduxjs/toolkit'),\n '@strapi/design-system': getModulePath('@strapi/design-system'),\n '@radix-ui/react-tooltip': getModulePath('@radix-ui/react-tooltip'),\n lodash: getModulePath('lodash'),\n },\n },\n plugins: [react(), buildFilesPlugin(ctx)],\n };\n};\n\nconst resolveProductionConfig = async (ctx: BuildContext): Promise<InlineConfig> => {\n const {\n options: { minify, sourcemaps },\n } = ctx;\n\n const baseConfig = await resolveBaseConfig(ctx);\n\n return {\n ...baseConfig,\n logLevel: 'silent',\n mode: 'production',\n build: {\n ...baseConfig.build,\n assetsDir: '',\n minify,\n sourcemap: sourcemaps,\n rollupOptions: {\n input: {\n strapi: ctx.entry,\n },\n },\n },\n };\n};\n\nconst resolveDevelopmentConfig = async (ctx: BuildContext): Promise<InlineConfig> => {\n const monorepo = await loadStrapiMonorepo(ctx.cwd);\n const baseConfig = await resolveBaseConfig(ctx);\n\n return {\n ...baseConfig,\n mode: 'development',\n resolve: {\n ...baseConfig.resolve,\n alias: {\n ...baseConfig.resolve?.alias,\n ...getMonorepoAliases({ monorepo }),\n },\n },\n server: {\n cors: false,\n /**\n * In middleware mode Strapi forwards the browser Host from reverse proxies (nginx, Traefik).\n * Vite 5+ blocks unknown hosts unless explicitly allowed (#23491).\n */\n allowedHosts: true,\n middlewareMode: true,\n open: ctx.options.open,\n hmr: {\n overlay: false,\n /**\n * Use Strapi's http.Server so HMR websockets reuse the app's listen port. A separate listener\n * plus clientPort pushes browsers toward host:5173-style URLs that fail behind proxies that\n * only expose the Strapi server port (#23491, #23008).\n */\n server: ctx.strapi.server.httpServer,\n },\n },\n appType: 'custom',\n };\n};\n\nconst USER_CONFIGS = ['vite.config.js', 'vite.config.mjs', 'vite.config.ts', 'vite.config.mts'];\n\ntype UserViteConfig = (config: UserConfig) => UserConfig;\n\nconst mergeConfigWithUserConfig = async (config: InlineConfig, ctx: BuildContext) => {\n const userConfig = await getUserConfig<UserViteConfig>(USER_CONFIGS, ctx);\n\n if (userConfig) {\n return userConfig(config);\n }\n\n return config;\n};\n\nexport { mergeConfigWithUserConfig, resolveProductionConfig, resolveDevelopmentConfig };\n"],"names":["resolveBaseConfig","ctx","default","browserslistToEsbuild","target","isMonorepoExampleApp","strapi","internal_config","uuid","designSystemLinked","isDesignSystemLinked","root","cwd","base","basePath","build","emptyOutDir","outDir","distDir","cacheDir","configFile","define","process","JSON","stringify","env","envPrefix","optimizeDeps","exclude","include","resolve","dedupe","alias","react","getModulePath","lodash","plugins","buildFilesPlugin","resolveProductionConfig","options","minify","sourcemaps","baseConfig","logLevel","mode","assetsDir","sourcemap","rollupOptions","input","entry","resolveDevelopmentConfig","monorepo","loadStrapiMonorepo","getMonorepoAliases","server","cors","allowedHosts","middlewareMode","open","hmr","overlay","httpServer","appType","USER_CONFIGS","mergeConfigWithUserConfig","config","userConfig","getUserConfig"],"mappings":";;;;;;;;;;;;;;AAWA,MAAMA,oBAAoB,OAAOC,GAAAA,GAAAA;AAC/B,IAAA,MAAM,EAAEC,OAAAA,EAASC,qBAAqB,EAAE,GAAG,MAAM,OAAO,yBAAA,CAAA;IACxD,MAAMC,MAAAA,GAASD,qBAAAA,CAAsBF,GAAAA,CAAIG,MAAM,CAAA;AAC/C,IAAA,MAAMC,uBAAuB,GAACJ,CAAIK,MAAM,CAASC,eAAe,EAAEC,IAAAA,KAAS,YAAA;AAC3E,IAAA,MAAMC,kBAAAA,GA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AEF,8BAAAA;iBAAS;AACnC;AACF,SAAA;QACAG,MAAAA,EAAQ;YACNC,IAAAA,EAAM,KAAA;AACN;;;AAGC,UACDC,YAAAA,EAAc,IAAA;YACdC,cAAAA,EAAgB,IAAA;YAChBC,IAAAA,EAAMzD,GAAAA,CAAIsC,OAAO,CAACmB,IAAI;YACtBC,GAAAA,EAAK;gBACHC,OAAAA,EAAS,KAAA;AACT;;;;AAIC,YACDN,QAAQrD,GAAAA,CAAIK,MAAM,CAACgD,MAAM,CAACO;AAC5B;AACF,SAAA;QACAC,OAAAA,EAAS;AACX,KAAA;AACF;AAEA,MAAMC,YAAAA,GAAe;AAAC,IAAA,gBAAA;AAAkB,IAAA,iBAAA;AAAmB,IAAA,gBAAA;AAAkB,IAAA;AAAkB,CAAA;AAI/F,MAAMC,yBAAAA,GAA4B,OAAOC,QAAAA,EAAsBhE,GAAAA,GAAAA;IAC7D,MAAMiE,UAAAA,GAAa,MAAMC,oBAAAA,CAA8BJ,YAAAA,EAAc9D,GAAAA,CAAAA;AAErE,IAAA,IAAIiE,UAAAA,EAAY;AACd,QAAA,OAAOA,UAAAA,CAAWD,QAAAA,CAAAA;AACpB,IAAA;IAEA,OAAOA,QAAAA;AACT;;;;;;"}
|
|
@@ -191,12 +191,19 @@ const resolveDevelopmentConfig = async (ctx)=>{
|
|
|
191
191
|
},
|
|
192
192
|
server: {
|
|
193
193
|
cors: false,
|
|
194
|
+
/**
|
|
195
|
+
* In middleware mode Strapi forwards the browser Host from reverse proxies (nginx, Traefik).
|
|
196
|
+
* Vite 5+ blocks unknown hosts unless explicitly allowed (#23491).
|
|
197
|
+
*/ allowedHosts: true,
|
|
194
198
|
middlewareMode: true,
|
|
195
199
|
open: ctx.options.open,
|
|
196
200
|
hmr: {
|
|
197
201
|
overlay: false,
|
|
198
|
-
|
|
199
|
-
|
|
202
|
+
/**
|
|
203
|
+
* Use Strapi's http.Server so HMR websockets reuse the app's listen port. A separate listener
|
|
204
|
+
* plus clientPort pushes browsers toward host:5173-style URLs that fail behind proxies that
|
|
205
|
+
* only expose the Strapi server port (#23491, #23008).
|
|
206
|
+
*/ server: ctx.strapi.server.httpServer
|
|
200
207
|
}
|
|
201
208
|
},
|
|
202
209
|
appType: 'custom'
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config.mjs","sources":["../../../../src/node/vite/config.ts"],"sourcesContent":["import type { InlineConfig, UserConfig } from 'vite';\nimport react from '@vitejs/plugin-react-swc';\n\nimport { getUserConfig } from '../core/config';\nimport { getModulePath } from '../core/resolve-module';\nimport { isDesignSystemLinked } from '../core/linked-packages';\nimport { loadStrapiMonorepo } from '../core/monorepo';\nimport { getMonorepoAliases } from '../core/aliases';\nimport type { BuildContext } from '../create-build-context';\nimport { buildFilesPlugin } from './plugins';\n\nconst resolveBaseConfig = async (ctx: BuildContext): Promise<InlineConfig> => {\n const { default: browserslistToEsbuild } = await import('browserslist-to-esbuild');\n const target = browserslistToEsbuild(ctx.target);\n const isMonorepoExampleApp = (ctx.strapi as any).internal_config?.uuid === 'getstarted';\n const designSystemLinked = isDesignSystemLinked();\n\n return {\n root: ctx.cwd,\n base: ctx.basePath,\n build: {\n emptyOutDir: false, // Rely on CLI to do this\n outDir: ctx.distDir,\n target,\n },\n cacheDir: 'node_modules/.strapi/vite',\n configFile: false,\n define: {\n process: {},\n 'process.env': JSON.stringify(ctx.env),\n },\n envPrefix: 'STRAPI_ADMIN_',\n optimizeDeps: {\n // When design-system is linked (portal:, file:, yarn link), exclude from pre-bundling\n // so changes are reflected without clearing node_modules/.strapi/vite cache\n ...(designSystemLinked && { exclude: ['@strapi/design-system'] }),\n include: [\n // pre-bundle React dependencies to avoid React duplicates,\n // even if React dependencies are not direct dependencies\n // https://react.dev/warnings/invalid-hook-call-warning#duplicate-react\n 'react',\n `react/jsx-runtime`,\n 'react-dom/client',\n 'styled-components',\n 'react-router-dom',\n // Admin + RTK Query share react-redux context; pre-bundle so dev chunks cannot load a\n // second copy (avoids \"could not find react-redux context value\" after upgrades / hoisting).\n 'react-redux',\n '@reduxjs/toolkit',\n // Pre-bundle design-system so plugin custom field chunks (dynamic imports) resolve\n // to the same instance as the main app. Otherwise TooltipProvider/DesignSystemProvider\n // context from the root is not seen by components in plugin chunks.\n // Omit when linked so local changes are picked up (see exclude above)\n ...(!designSystemLinked ? ['@strapi/design-system'] : []),\n '@radix-ui/react-tooltip',\n // Pre-bundle lodash: design-system uses named imports (e.g. assignWith) but lodash\n // is CommonJS-only; pre-bundling converts it to ESM for the browser\n 'lodash',\n // Pre-bundle prismjs so plugin chunks get a valid ESM namespace (prismjs is UMD and can\n // otherwise expose an empty object when bundled, causing \"Prism is not defined\" in admin).\n 'prismjs',\n /**\n * Pre-bundle other dependencies that would otherwise cause a page reload when imported.\n * See \"performance\" section: https://vite.dev/guide/dep-pre-bundling.html#the-why\n * Only include dependencies for our internal example apps, otherwise it will break\n * real user apps that may not have those dependencies.\n */\n ...(isMonorepoExampleApp\n ? [\n '@dnd-kit/core',\n '@dnd-kit/sortable',\n '@dnd-kit/utilities',\n '@dnd-kit/modifiers',\n '@radix-ui/react-toolbar',\n 'codemirror5',\n 'codemirror5/addon/display/placeholder',\n 'date-fns-tz',\n 'date-fns/format',\n 'date-fns/formatISO',\n 'highlight.js',\n 'lodash/capitalize',\n 'lodash/fp',\n 'lodash/groupBy',\n 'lodash/has',\n 'lodash/isNil',\n 'lodash/locale',\n 'lodash/map',\n 'lodash/mapValues',\n 'lodash/pull',\n 'lodash/size',\n 'lodash/sortBy',\n 'lodash/tail',\n 'lodash/toLower',\n 'lodash/toNumber',\n 'lodash/toString',\n 'lodash/truncate',\n 'lodash/uniq',\n 'lodash/upperFirst',\n 'markdown-it',\n 'markdown-it-abbr',\n 'markdown-it-container',\n 'markdown-it-deflist',\n 'markdown-it-emoji',\n 'markdown-it-footnote',\n 'markdown-it-ins',\n 'markdown-it-mark',\n 'markdown-it-sub',\n 'markdown-it-sup',\n 'prismjs/components/*.js',\n 'react-colorful',\n 'react-dnd-html5-backend',\n 'react-window',\n 'semver',\n 'semver/functions/lt',\n 'semver/functions/valid',\n 'slate',\n 'slate-history',\n 'slate-react',\n 'motion',\n ]\n : []),\n ],\n },\n resolve: {\n // https://react.dev/warnings/invalid-hook-call-warning#duplicate-react\n // Include design-system so plugin chunks use the same instance and inherit root context\n dedupe: [\n 'react',\n 'react-dom',\n 'react-router-dom',\n 'styled-components',\n 'react-redux',\n '@reduxjs/toolkit',\n '@strapi/design-system',\n '@radix-ui/react-tooltip',\n 'lodash',\n ],\n // Explicit aliases ensure resolution under pnpm's strict dependency isolation,\n // where packages imported by plugins may not be resolvable from plugin chunks\n alias: {\n react: getModulePath('react'),\n 'react-dom': getModulePath('react-dom'),\n 'react-router-dom': getModulePath('react-router-dom'),\n 'styled-components': getModulePath('styled-components'),\n 'react-redux': getModulePath('react-redux'),\n '@reduxjs/toolkit': getModulePath('@reduxjs/toolkit'),\n '@strapi/design-system': getModulePath('@strapi/design-system'),\n '@radix-ui/react-tooltip': getModulePath('@radix-ui/react-tooltip'),\n lodash: getModulePath('lodash'),\n },\n },\n plugins: [react(), buildFilesPlugin(ctx)],\n };\n};\n\nconst resolveProductionConfig = async (ctx: BuildContext): Promise<InlineConfig> => {\n const {\n options: { minify, sourcemaps },\n } = ctx;\n\n const baseConfig = await resolveBaseConfig(ctx);\n\n return {\n ...baseConfig,\n logLevel: 'silent',\n mode: 'production',\n build: {\n ...baseConfig.build,\n assetsDir: '',\n minify,\n sourcemap: sourcemaps,\n rollupOptions: {\n input: {\n strapi: ctx.entry,\n },\n },\n },\n };\n};\n\nconst resolveDevelopmentConfig = async (ctx: BuildContext): Promise<InlineConfig> => {\n const monorepo = await loadStrapiMonorepo(ctx.cwd);\n const baseConfig = await resolveBaseConfig(ctx);\n\n return {\n ...baseConfig,\n mode: 'development',\n resolve: {\n ...baseConfig.resolve,\n alias: {\n ...baseConfig.resolve?.alias,\n ...getMonorepoAliases({ monorepo }),\n },\n },\n server: {\n cors: false,\n middlewareMode: true,\n open: ctx.options.open,\n hmr: {\n overlay: false,\n server: ctx.options.hmrServer,\n clientPort: ctx.options.hmrClientPort,\n },\n },\n appType: 'custom',\n };\n};\n\nconst USER_CONFIGS = ['vite.config.js', 'vite.config.mjs', 'vite.config.ts', 'vite.config.mts'];\n\ntype UserViteConfig = (config: UserConfig) => UserConfig;\n\nconst mergeConfigWithUserConfig = async (config: InlineConfig, ctx: BuildContext) => {\n const userConfig = await getUserConfig<UserViteConfig>(USER_CONFIGS, ctx);\n\n if (userConfig) {\n return userConfig(config);\n }\n\n return config;\n};\n\nexport { mergeConfigWithUserConfig, resolveProductionConfig, resolveDevelopmentConfig };\n"],"names":["resolveBaseConfig","ctx","default","browserslistToEsbuild","target","isMonorepoExampleApp","strapi","internal_config","uuid","designSystemLinked","isDesignSystemLinked","root","cwd","base","basePath","build","emptyOutDir","outDir","distDir","cacheDir","configFile","define","process","JSON","stringify","env","envPrefix","optimizeDeps","exclude","include","resolve","dedupe","alias","react","getModulePath","lodash","plugins","buildFilesPlugin","resolveProductionConfig","options","minify","sourcemaps","baseConfig","logLevel","mode","assetsDir","sourcemap","rollupOptions","input","entry","resolveDevelopmentConfig","monorepo","loadStrapiMonorepo","getMonorepoAliases","server","cors","middlewareMode","open","hmr","overlay","hmrServer","clientPort","hmrClientPort","appType","USER_CONFIGS","mergeConfigWithUserConfig","config","userConfig","getUserConfig"],"mappings":";;;;;;;;AAWA,MAAMA,oBAAoB,OAAOC,GAAAA,GAAAA;AAC/B,IAAA,MAAM,EAAEC,OAAAA,EAASC,qBAAqB,EAAE,GAAG,MAAM,OAAO,yBAAA,CAAA;IACxD,MAAMC,MAAAA,GAASD,qBAAAA,CAAsBF,GAAAA,CAAIG,MAAM,CAAA;AAC/C,IAAA,MAAMC,uBAAuB,GAACJ,CAAIK,MAAM,CAASC,eAAe,EAAEC,IAAAA,KAAS,YAAA;AAC3E,IAAA,MAAMC,kBAAAA,GAAqBC,oBAAAA,EAAAA;IAE3B,OAAO;A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A,EAAQ;YACNC,IAAAA,EAAM,KAAA;YACNC,cAAAA,EAAgB,IAAA;YAChBC,IAAAA,EAAMxD,GAAAA,CAAIsC,OAAO,CAACkB,IAAI;YACtBC,GAAAA,EAAK;gBACHC,OAAAA,EAAS,KAAA;gBACTL,MAAAA,EAAQrD,GAAAA,CAAIsC,OAAO,CAACqB,SAAS;gBAC7BC,UAAAA,EAAY5D,GAAAA,CAAIsC,OAAO,CAACuB;AAC1B;AACF,SAAA;QACAC,OAAAA,EAAS;AACX,KAAA;AACF;AAEA,MAAMC,YAAAA,GAAe;AAAC,IAAA,gBAAA;AAAkB,IAAA,iBAAA;AAAmB,IAAA,gBAAA;AAAkB,IAAA;AAAkB,CAAA;AAI/F,MAAMC,yBAAAA,GAA4B,OAAOC,MAAAA,EAAsBjE,GAAAA,GAAAA;IAC7D,MAAMkE,UAAAA,GAAa,MAAMC,aAAAA,CAA8BJ,YAAAA,EAAc/D,GAAAA,CAAAA;AAErE,IAAA,IAAIkE,UAAAA,EAAY;AACd,QAAA,OAAOA,UAAAA,CAAWD,MAAAA,CAAAA;AACpB,IAAA;IAEA,OAAOA,MAAAA;AACT;;;;"}
|
|
1
|
+
{"version":3,"file":"config.mjs","sources":["../../../../src/node/vite/config.ts"],"sourcesContent":["import type { InlineConfig, UserConfig } from 'vite';\nimport react from '@vitejs/plugin-react-swc';\n\nimport { getUserConfig } from '../core/config';\nimport { getModulePath } from '../core/resolve-module';\nimport { isDesignSystemLinked } from '../core/linked-packages';\nimport { loadStrapiMonorepo } from '../core/monorepo';\nimport { getMonorepoAliases } from '../core/aliases';\nimport type { BuildContext } from '../create-build-context';\nimport { buildFilesPlugin } from './plugins';\n\nconst resolveBaseConfig = async (ctx: BuildContext): Promise<InlineConfig> => {\n const { default: browserslistToEsbuild } = await import('browserslist-to-esbuild');\n const target = browserslistToEsbuild(ctx.target);\n const isMonorepoExampleApp = (ctx.strapi as any).internal_config?.uuid === 'getstarted';\n const designSystemLinked = isDesignSystemLinked();\n\n return {\n root: ctx.cwd,\n base: ctx.basePath,\n build: {\n emptyOutDir: false, // Rely on CLI to do this\n outDir: ctx.distDir,\n target,\n },\n cacheDir: 'node_modules/.strapi/vite',\n configFile: false,\n define: {\n process: {},\n 'process.env': JSON.stringify(ctx.env),\n },\n envPrefix: 'STRAPI_ADMIN_',\n optimizeDeps: {\n // When design-system is linked (portal:, file:, yarn link), exclude from pre-bundling\n // so changes are reflected without clearing node_modules/.strapi/vite cache\n ...(designSystemLinked && { exclude: ['@strapi/design-system'] }),\n include: [\n // pre-bundle React dependencies to avoid React duplicates,\n // even if React dependencies are not direct dependencies\n // https://react.dev/warnings/invalid-hook-call-warning#duplicate-react\n 'react',\n `react/jsx-runtime`,\n 'react-dom/client',\n 'styled-components',\n 'react-router-dom',\n // Admin + RTK Query share react-redux context; pre-bundle so dev chunks cannot load a\n // second copy (avoids \"could not find react-redux context value\" after upgrades / hoisting).\n 'react-redux',\n '@reduxjs/toolkit',\n // Pre-bundle design-system so plugin custom field chunks (dynamic imports) resolve\n // to the same instance as the main app. Otherwise TooltipProvider/DesignSystemProvider\n // context from the root is not seen by components in plugin chunks.\n // Omit when linked so local changes are picked up (see exclude above)\n ...(!designSystemLinked ? ['@strapi/design-system'] : []),\n '@radix-ui/react-tooltip',\n // Pre-bundle lodash: design-system uses named imports (e.g. assignWith) but lodash\n // is CommonJS-only; pre-bundling converts it to ESM for the browser\n 'lodash',\n // Pre-bundle prismjs so plugin chunks get a valid ESM namespace (prismjs is UMD and can\n // otherwise expose an empty object when bundled, causing \"Prism is not defined\" in admin).\n 'prismjs',\n /**\n * Pre-bundle other dependencies that would otherwise cause a page reload when imported.\n * See \"performance\" section: https://vite.dev/guide/dep-pre-bundling.html#the-why\n * Only include dependencies for our internal example apps, otherwise it will break\n * real user apps that may not have those dependencies.\n */\n ...(isMonorepoExampleApp\n ? [\n '@dnd-kit/core',\n '@dnd-kit/sortable',\n '@dnd-kit/utilities',\n '@dnd-kit/modifiers',\n '@radix-ui/react-toolbar',\n 'codemirror5',\n 'codemirror5/addon/display/placeholder',\n 'date-fns-tz',\n 'date-fns/format',\n 'date-fns/formatISO',\n 'highlight.js',\n 'lodash/capitalize',\n 'lodash/fp',\n 'lodash/groupBy',\n 'lodash/has',\n 'lodash/isNil',\n 'lodash/locale',\n 'lodash/map',\n 'lodash/mapValues',\n 'lodash/pull',\n 'lodash/size',\n 'lodash/sortBy',\n 'lodash/tail',\n 'lodash/toLower',\n 'lodash/toNumber',\n 'lodash/toString',\n 'lodash/truncate',\n 'lodash/uniq',\n 'lodash/upperFirst',\n 'markdown-it',\n 'markdown-it-abbr',\n 'markdown-it-container',\n 'markdown-it-deflist',\n 'markdown-it-emoji',\n 'markdown-it-footnote',\n 'markdown-it-ins',\n 'markdown-it-mark',\n 'markdown-it-sub',\n 'markdown-it-sup',\n 'prismjs/components/*.js',\n 'react-colorful',\n 'react-dnd-html5-backend',\n 'react-window',\n 'semver',\n 'semver/functions/lt',\n 'semver/functions/valid',\n 'slate',\n 'slate-history',\n 'slate-react',\n 'motion',\n ]\n : []),\n ],\n },\n resolve: {\n // https://react.dev/warnings/invalid-hook-call-warning#duplicate-react\n // Include design-system so plugin chunks use the same instance and inherit root context\n dedupe: [\n 'react',\n 'react-dom',\n 'react-router-dom',\n 'styled-components',\n 'react-redux',\n '@reduxjs/toolkit',\n '@strapi/design-system',\n '@radix-ui/react-tooltip',\n 'lodash',\n ],\n // Explicit aliases ensure resolution under pnpm's strict dependency isolation,\n // where packages imported by plugins may not be resolvable from plugin chunks\n alias: {\n react: getModulePath('react'),\n 'react-dom': getModulePath('react-dom'),\n 'react-router-dom': getModulePath('react-router-dom'),\n 'styled-components': getModulePath('styled-components'),\n 'react-redux': getModulePath('react-redux'),\n '@reduxjs/toolkit': getModulePath('@reduxjs/toolkit'),\n '@strapi/design-system': getModulePath('@strapi/design-system'),\n '@radix-ui/react-tooltip': getModulePath('@radix-ui/react-tooltip'),\n lodash: getModulePath('lodash'),\n },\n },\n plugins: [react(), buildFilesPlugin(ctx)],\n };\n};\n\nconst resolveProductionConfig = async (ctx: BuildContext): Promise<InlineConfig> => {\n const {\n options: { minify, sourcemaps },\n } = ctx;\n\n const baseConfig = await resolveBaseConfig(ctx);\n\n return {\n ...baseConfig,\n logLevel: 'silent',\n mode: 'production',\n build: {\n ...baseConfig.build,\n assetsDir: '',\n minify,\n sourcemap: sourcemaps,\n rollupOptions: {\n input: {\n strapi: ctx.entry,\n },\n },\n },\n };\n};\n\nconst resolveDevelopmentConfig = async (ctx: BuildContext): Promise<InlineConfig> => {\n const monorepo = await loadStrapiMonorepo(ctx.cwd);\n const baseConfig = await resolveBaseConfig(ctx);\n\n return {\n ...baseConfig,\n mode: 'development',\n resolve: {\n ...baseConfig.resolve,\n alias: {\n ...baseConfig.resolve?.alias,\n ...getMonorepoAliases({ monorepo }),\n },\n },\n server: {\n cors: false,\n /**\n * In middleware mode Strapi forwards the browser Host from reverse proxies (nginx, Traefik).\n * Vite 5+ blocks unknown hosts unless explicitly allowed (#23491).\n */\n allowedHosts: true,\n middlewareMode: true,\n open: ctx.options.open,\n hmr: {\n overlay: false,\n /**\n * Use Strapi's http.Server so HMR websockets reuse the app's listen port. A separate listener\n * plus clientPort pushes browsers toward host:5173-style URLs that fail behind proxies that\n * only expose the Strapi server port (#23491, #23008).\n */\n server: ctx.strapi.server.httpServer,\n },\n },\n appType: 'custom',\n };\n};\n\nconst USER_CONFIGS = ['vite.config.js', 'vite.config.mjs', 'vite.config.ts', 'vite.config.mts'];\n\ntype UserViteConfig = (config: UserConfig) => UserConfig;\n\nconst mergeConfigWithUserConfig = async (config: InlineConfig, ctx: BuildContext) => {\n const userConfig = await getUserConfig<UserViteConfig>(USER_CONFIGS, ctx);\n\n if (userConfig) {\n return userConfig(config);\n }\n\n return config;\n};\n\nexport { mergeConfigWithUserConfig, resolveProductionConfig, resolveDevelopmentConfig };\n"],"names":["resolveBaseConfig","ctx","default","browserslistToEsbuild","target","isMonorepoExampleApp","strapi","internal_config","uuid","designSystemLinked","isDesignSystemLinked","root","cwd","base","basePath","build","emptyOutDir","outDir","distDir","cacheDir","configFile","define","process","JSON","stringify","env","envPrefix","optimizeDeps","exclude","include","resolve","dedupe","alias","react","getModulePath","lodash","plugins","buildFilesPlugin","resolveProductionConfig","options","minify","sourcemaps","baseConfig","logLevel","mode","assetsDir","sourcemap","rollupOptions","input","entry","resolveDevelopmentConfig","monorepo","loadStrapiMonorepo","getMonorepoAliases","server","cors","allowedHosts","middlewareMode","open","hmr","overlay","httpServer","appType","USER_CONFIGS","mergeConfigWithUserConfig","config","userConfig","getUserConfig"],"mappings":";;;;;;;;AAWA,MAAMA,oBAAoB,OAAOC,GAAAA,GAAAA;AAC/B,IAAA,MAAM,EAAEC,OAAAA,EAASC,qBAAqB,EAAE,GAAG,MAAM,OAAO,yBAAA,CAAA;IACxD,MAAMC,MAAAA,GAASD,qBAAAA,CAAsBF,GAAAA,CAAIG,MAAM,CAAA;AAC/C,IAAA,MAAMC,uBAAuB,GAACJ,CAAIK,MAAM,CAASC,eAAe,EAAEC,IAAAA,KAAS,YAAA;AAC3E,IAAA,MAAMC,kBAAAA,GAAqBC,oBAAAA,EAAAA;IAE3B,OAAO;AACLC,QAAAA,IAAAA,EAAMV,IAAIW,GAAG;AACbC,QAAAA,IAAAA,EAAMZ,IAAIa,QAAQ;QAClBC,KAAAA,EAAO;YACLC,WAAAA,EAAa,KAAA;AACbC,YAAAA,MAAAA,EAAQhB,IAAIiB,OAAO;AACnBd,YAAAA;AACF,SAAA;QACAe,QAAAA,EAAU,2BAAA;QACVC,UAAAA,EAAY,KAAA;QACZC,MAAAA,EAAQ;AACNC,YAAAA,OAAAA,EAAS,EAAC;AACV,YAAA,aAAA,EAAeC,IAAAA,CAAKC,SAAS,CAACvB,GAAAA,CAAIwB,GAAG;AACvC,SAAA;QACAC,SAAAA,EAAW,eAAA;QACXC,YAAAA,EAAc;;;AAGZ,YAAA,GAAIlB,kBAAAA,IAAsB;gBAAEmB,OAAAA,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BhE,GAAAA,GAAAA;IAC7D,MAAMiE,UAAAA,GAAa,MAAMC,aAAAA,CAA8BJ,YAAAA,EAAc9D,GAAAA,CAAAA;AAErE,IAAA,IAAIiE,UAAAA,EAAY;AACd,QAAA,OAAOA,UAAAA,CAAWD,MAAAA,CAAAA;AACpB,IAAA;IAEA,OAAOA,MAAAA;AACT;;;;"}
|
|
@@ -1,63 +1,16 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
3
|
var path = require('node:path');
|
|
4
|
-
var http = require('node:http');
|
|
5
4
|
var fs = require('node:fs/promises');
|
|
6
|
-
var node_net = require('node:net');
|
|
7
5
|
var config = require('./config.js');
|
|
8
6
|
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
reject(new Error(`No available ports found after ${MAX_PORT_ATTEMPTS} attempts.`));
|
|
15
|
-
return;
|
|
16
|
-
}
|
|
17
|
-
const server = new node_net.Server();
|
|
18
|
-
server.listen(startingPort, ()=>{
|
|
19
|
-
const { port } = server.address();
|
|
20
|
-
server.close(()=>resolve(port));
|
|
21
|
-
});
|
|
22
|
-
server.on('error', (err)=>{
|
|
23
|
-
if (err.code === 'EADDRINUSE') {
|
|
24
|
-
resolve(findAvailablePort(startingPort + 1, attemptsLeft - 1));
|
|
25
|
-
} else {
|
|
26
|
-
reject(err);
|
|
27
|
-
}
|
|
28
|
-
});
|
|
29
|
-
});
|
|
30
|
-
};
|
|
31
|
-
const createHMRServer = ()=>{
|
|
32
|
-
return http.createServer(// http server request handler. keeps the same with
|
|
33
|
-
// https://github.com/websockets/ws/blob/45e17acea791d865df6b255a55182e9c42e5877a/lib/websocket-server.js#L88-L96
|
|
34
|
-
(_, res)=>{
|
|
35
|
-
const body = http.STATUS_CODES[426]; // Upgrade Required
|
|
36
|
-
res.writeHead(426, {
|
|
37
|
-
'Content-Length': body?.length ?? 0,
|
|
38
|
-
'Content-Type': 'text/plain'
|
|
39
|
-
});
|
|
40
|
-
res.end(body);
|
|
41
|
-
});
|
|
42
|
-
};
|
|
7
|
+
function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
|
|
8
|
+
|
|
9
|
+
var path__default = /*#__PURE__*/_interopDefault(path);
|
|
10
|
+
var fs__default = /*#__PURE__*/_interopDefault(fs);
|
|
11
|
+
|
|
43
12
|
const watch = async (ctx)=>{
|
|
44
|
-
const
|
|
45
|
-
// Allowing Vite to find an available port doesn't work, so we'll find an available port manually
|
|
46
|
-
// and use that. There is therefore a very slight race condition if you start up two servers at the same time
|
|
47
|
-
// one might fail, or it might start up but listen on the wrong port.
|
|
48
|
-
const availablePort = await findAvailablePort(HMR_DEFAULT_PORT);
|
|
49
|
-
ctx.options.hmrServer = hmrServer;
|
|
50
|
-
ctx.options.hmrClientPort = availablePort;
|
|
51
|
-
const config$1 = await config.resolveDevelopmentConfig(ctx);
|
|
52
|
-
const finalConfig = await config.mergeConfigWithUserConfig(config$1, ctx);
|
|
53
|
-
const hmrConfig = config$1.server?.hmr;
|
|
54
|
-
// If the server used for Vite hmr is the one we've created (<> no user override)
|
|
55
|
-
if (typeof hmrConfig === 'object' && hmrConfig.server === hmrServer) {
|
|
56
|
-
// Only restart the hmr server when Strapi's server is listening
|
|
57
|
-
strapi.server.httpServer.on('listening', async ()=>{
|
|
58
|
-
hmrServer.listen(availablePort);
|
|
59
|
-
});
|
|
60
|
-
}
|
|
13
|
+
const finalConfig = await config.mergeConfigWithUserConfig(await config.resolveDevelopmentConfig(ctx), ctx);
|
|
61
14
|
ctx.logger.debug('Vite config', finalConfig);
|
|
62
15
|
const { createServer } = await import('vite');
|
|
63
16
|
const vite = await createServer(finalConfig);
|
|
@@ -95,7 +48,7 @@ const watch = async (ctx)=>{
|
|
|
95
48
|
}
|
|
96
49
|
const url = koaCtx.originalUrl;
|
|
97
50
|
try {
|
|
98
|
-
let template = await
|
|
51
|
+
let template = await fs__default.default.readFile(path__default.default.relative(ctx.cwd, '.strapi/client/index.html'), 'utf-8');
|
|
99
52
|
template = await vite.transformIndexHtml(url, template);
|
|
100
53
|
koaCtx.type = 'html';
|
|
101
54
|
koaCtx.body = template;
|
|
@@ -120,14 +73,6 @@ const watch = async (ctx)=>{
|
|
|
120
73
|
return {
|
|
121
74
|
async close () {
|
|
122
75
|
await vite.close();
|
|
123
|
-
if (hmrServer.listening) {
|
|
124
|
-
// Manually close the hmr server
|
|
125
|
-
// /!\ This operation MUST be done after calling .close() on the vite
|
|
126
|
-
// instance to avoid flaky behaviors with attached clients
|
|
127
|
-
await new Promise((resolve, reject)=>{
|
|
128
|
-
hmrServer.close((err)=>err ? reject(err) : resolve());
|
|
129
|
-
});
|
|
130
|
-
}
|
|
131
76
|
}
|
|
132
77
|
};
|
|
133
78
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"watch.js","sources":["../../../../src/node/vite/watch.ts"],"sourcesContent":["import path from 'node:path';\nimport http from 'node:http';\nimport fs from 'node:fs/promises';\nimport { Server } from 'node:net';\nimport type { Core } from '@strapi/types';\n\nimport { mergeConfigWithUserConfig, resolveDevelopmentConfig } from './config';\n\nimport type { BuildContext } from '../create-build-context';\n\ninterface ViteWatcher {\n close(): Promise<void>;\n}\n\nconst HMR_DEFAULT_PORT = 5173;\nconst MAX_PORT_ATTEMPTS = 30;\n\nconst findAvailablePort = (\n startingPort: number,\n attemptsLeft = MAX_PORT_ATTEMPTS\n): Promise<number> => {\n return new Promise((resolve, reject) => {\n if (attemptsLeft <= 0) {\n reject(new Error(`No available ports found after ${MAX_PORT_ATTEMPTS} attempts.`));\n return;\n }\n\n const server = new Server();\n server.listen(startingPort, () => {\n const { port } = server.address() as { port: number };\n server.close(() => resolve(port));\n });\n\n server.on('error', (err: any) => {\n if (err.code === 'EADDRINUSE') {\n resolve(findAvailablePort(startingPort + 1, attemptsLeft - 1));\n } else {\n reject(err);\n }\n });\n });\n};\n\nconst createHMRServer = () => {\n return http.createServer(\n // http server request handler. keeps the same with\n // https://github.com/websockets/ws/blob/45e17acea791d865df6b255a55182e9c42e5877a/lib/websocket-server.js#L88-L96\n (_, res) => {\n const body = http.STATUS_CODES[426]; // Upgrade Required\n\n res.writeHead(426, {\n 'Content-Length': body?.length ?? 0,\n 'Content-Type': 'text/plain',\n });\n\n res.end(body);\n }\n );\n};\n\nconst watch = async (ctx: BuildContext): Promise<ViteWatcher> => {\n const hmrServer = createHMRServer();\n\n // Allowing Vite to find an available port doesn't work, so we'll find an available port manually\n // and use that. There is therefore a very slight race condition if you start up two servers at the same time\n // one might fail, or it might start up but listen on the wrong port.\n const availablePort = await findAvailablePort(HMR_DEFAULT_PORT);\n ctx.options.hmrServer = hmrServer;\n ctx.options.hmrClientPort = availablePort;\n\n const config = await resolveDevelopmentConfig(ctx);\n\n const finalConfig = await mergeConfigWithUserConfig(config, ctx);\n\n const hmrConfig = config.server?.hmr;\n\n // If the server used for Vite hmr is the one we've created (<> no user override)\n if (typeof hmrConfig === 'object' && hmrConfig.server === hmrServer) {\n // Only restart the hmr server when Strapi's server is listening\n strapi.server.httpServer.on('listening', async () => {\n hmrServer.listen(availablePort);\n });\n }\n\n ctx.logger.debug('Vite config', finalConfig);\n\n const { createServer } = await import('vite');\n\n const vite = await createServer(finalConfig);\n\n const viteMiddlewares: Core.MiddlewareHandler = (koaCtx, next) => {\n return new Promise((resolve, reject) => {\n const prefix = ctx.basePath.replace(ctx.adminPath, '').replace(/\\/+$/, '');\n\n const originalPath = koaCtx.path;\n if (!koaCtx.path.startsWith(prefix)) {\n koaCtx.path = `${prefix}${koaCtx.path}`;\n }\n\n // Set cache-control headers to prevent caching issues during development restarts\n koaCtx.set('Cache-Control', 'no-store, no-cache, must-revalidate, proxy-revalidate');\n koaCtx.set('Pragma', 'no-cache');\n koaCtx.set('Expires', '0');\n koaCtx.set('Surrogate-Control', 'no-store');\n\n vite.middlewares(koaCtx.req, koaCtx.res, (err: unknown) => {\n if (err) {\n reject(err);\n } else {\n if (!koaCtx.res.headersSent) {\n koaCtx.path = originalPath;\n }\n\n resolve(next());\n }\n });\n });\n };\n\n const serveAdmin: Core.MiddlewareHandler = async (koaCtx, next) => {\n await next();\n\n if (koaCtx.method !== 'HEAD' && koaCtx.method !== 'GET') {\n return;\n }\n\n if (koaCtx.body != null || koaCtx.status !== 404) {\n return;\n }\n\n const url = koaCtx.originalUrl;\n\n try {\n let template = await fs.readFile(\n path.relative(ctx.cwd, '.strapi/client/index.html'),\n 'utf-8'\n );\n template = await vite.transformIndexHtml(url, template);\n\n koaCtx.type = 'html';\n koaCtx.body = template;\n } catch (error) {\n ctx.logger.error('Failed to serve admin panel in development mode:', error);\n // Don't fallback to other handlers in development mode to prevent MIME type conflicts\n koaCtx.status = 500;\n koaCtx.body = 'Admin panel temporarily unavailable during server restart';\n }\n };\n\n const adminRoute = `${ctx.adminPath}/:path*`;\n\n // Remove any existing admin routes to prevent conflicts during restart\n const existingRoutes = ctx.strapi.server.router.stack.filter(\n (layer) => layer.path === adminRoute\n );\n existingRoutes.forEach((route) => {\n const index = ctx.strapi.server.router.stack.indexOf(route);\n if (index > -1) {\n ctx.strapi.server.router.stack.splice(index, 1);\n }\n });\n\n ctx.strapi.server.router.get(adminRoute, serveAdmin);\n ctx.strapi.server.router.use(adminRoute, viteMiddlewares);\n\n return {\n async close() {\n await vite.close();\n\n if (hmrServer.listening) {\n // Manually close the hmr server\n // /!\\ This operation MUST be done after calling .close() on the vite\n // instance to avoid flaky behaviors with attached clients\n await new Promise<void>((resolve, reject) => {\n hmrServer.close((err) => (err ? reject(err) : resolve()));\n });\n }\n },\n };\n};\n\nexport { watch };\nexport type { ViteWatcher };\n"],"names":["HMR_DEFAULT_PORT","MAX_PORT_ATTEMPTS","findAvailablePort","startingPort","attemptsLeft","Promise","resolve","reject","Error","server","Server","listen","port","address","close","on","err","code","createHMRServer","http","createServer","_","res","body","STATUS_CODES","writeHead","length","end","watch","ctx","hmrServer","availablePort","options","hmrClientPort","config","resolveDevelopmentConfig","finalConfig","mergeConfigWithUserConfig","hmrConfig","hmr","strapi","httpServer","logger","debug","vite","viteMiddlewares","koaCtx","next","prefix","basePath","replace","adminPath","originalPath","path","startsWith","set","middlewares","req","headersSent","serveAdmin","method","status","url","originalUrl","template","fs","readFile","relative","cwd","transformIndexHtml","type","error","adminRoute","existingRoutes","router","stack","filter","layer","forEach","route","index","indexOf","splice","get","use","listening"],"mappings":";;;;;;;;AAcA,MAAMA,gBAAAA,GAAmB,IAAA;AACzB,MAAMC,iBAAAA,GAAoB,EAAA;AAE1B,MAAMC,iBAAAA,GAAoB,CACxBC,YAAAA,EACAC,YAAAA,GAAeH,iBAAiB,GAAA;IAEhC,OAAO,IAAII,OAAAA,CAAQ,CAACC,OAAAA,EAASC,MAAAA,GAAAA;AAC3B,QAAA,IAAIH,gBAAgB,CAAA,EAAG;AACrBG,YAAAA,MAAAA,CAAO,IAAIC,KAAAA,CAAM,CAAC,+BAA+B,EAAEP,iBAAAA,CAAkB,UAAU,CAAC,CAAA,CAAA;AAChF,YAAA;AACF,QAAA;AAEA,QAAA,MAAMQ,SAAS,IAAIC,eAAAA,EAAAA;QACnBD,MAAAA,CAAOE,MAAM,CAACR,YAAAA,EAAc,IAAA;AAC1B,YAAA,MAAM,EAAES,IAAI,EAAE,GAAGH,OAAOI,OAAO,EAAA;YAC/BJ,MAAAA,CAAOK,KAAK,CAAC,IAAMR,OAAAA,CAAQM,IAAAA,CAAAA,CAAAA;AAC7B,QAAA,CAAA,CAAA;QAEAH,MAAAA,CAAOM,EAAE,CAAC,OAAA,EAAS,CAACC,GAAAA,GAAAA;YAClB,IAAIA,GAAAA,CAAIC,IAAI,KAAK,YAAA,EAAc;gBAC7BX,OAAAA,CAAQJ,iBAAAA,CAAkBC,YAAAA,GAAe,CAAA,EAAGC,YAAAA,GAAe,CAAA,CAAA,CAAA;YAC7D,CAAA,MAAO;gBACLG,MAAAA,CAAOS,GAAAA,CAAAA;AACT,YAAA;AACF,QAAA,CAAA,CAAA;AACF,IAAA,CAAA,CAAA;AACF,CAAA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AAMsB,iBAAiB5C,GAAAA,CAAIW,MAAM,CAAC/B,MAAM,CAACiE,MAAM,CAACC,KAAK,CAACC,MAAM,CAC1D,CAACC,KAAAA,GAAUA,KAAAA,CAAMxB,IAAI,KAAKmB,UAAAA,CAAAA;IAE5BC,cAAAA,CAAeK,OAAO,CAAC,CAACC,KAAAA,GAAAA;QACtB,MAAMC,KAAAA,GAAQnD,GAAAA,CAAIW,MAAM,CAAC/B,MAAM,CAACiE,MAAM,CAACC,KAAK,CAACM,OAAO,CAACF,KAAAA,CAAAA;QACrD,IAAIC,KAAAA,GAAQ,EAAC,EAAG;YACdnD,GAAAA,CAAIW,MAAM,CAAC/B,MAAM,CAACiE,MAAM,CAACC,KAAK,CAACO,MAAM,CAACF,KAAAA,EAAO,CAAA,CAAA;AAC/C,QAAA;AACF,IAAA,CAAA,CAAA;IAEAnD,GAAAA,CAAIW,MAAM,CAAC/B,MAAM,CAACiE,MAAM,CAACS,GAAG,CAACX,UAAAA,EAAYb,UAAAA,CAAAA;IACzC9B,GAAAA,CAAIW,MAAM,CAAC/B,MAAM,CAACiE,MAAM,CAACU,GAAG,CAACZ,UAAAA,EAAY3B,eAAAA,CAAAA;IAEzC,OAAO;QACL,MAAM/B,KAAAA,CAAAA,GAAAA;AACJ,YAAA,MAAM8B,KAAK9B,KAAK,EAAA;YAEhB,IAAIgB,SAAAA,CAAUuD,SAAS,EAAE;;;;gBAIvB,MAAM,IAAIhF,OAAAA,CAAc,CAACC,OAAAA,EAASC,MAAAA,GAAAA;AAChCuB,oBAAAA,SAAAA,CAAUhB,KAAK,CAAC,CAACE,GAAAA,GAASA,GAAAA,GAAMT,OAAOS,GAAAA,CAAAA,GAAOV,OAAAA,EAAAA,CAAAA;AAChD,gBAAA,CAAA,CAAA;AACF,YAAA;AACF,QAAA;AACF,KAAA;AACF;;;;"}
|
|
1
|
+
{"version":3,"file":"watch.js","sources":["../../../../src/node/vite/watch.ts"],"sourcesContent":["import path from 'node:path';\nimport fs from 'node:fs/promises';\nimport type { Core } from '@strapi/types';\n\nimport { mergeConfigWithUserConfig, resolveDevelopmentConfig } from './config';\n\nimport type { BuildContext } from '../create-build-context';\n\ninterface ViteWatcher {\n close(): Promise<void>;\n}\n\nconst watch = async (ctx: BuildContext): Promise<ViteWatcher> => {\n const finalConfig = await mergeConfigWithUserConfig(await resolveDevelopmentConfig(ctx), ctx);\n\n ctx.logger.debug('Vite config', finalConfig);\n\n const { createServer } = await import('vite');\n\n const vite = await createServer(finalConfig);\n\n const viteMiddlewares: Core.MiddlewareHandler = (koaCtx, next) => {\n return new Promise((resolve, reject) => {\n const prefix = ctx.basePath.replace(ctx.adminPath, '').replace(/\\/+$/, '');\n\n const originalPath = koaCtx.path;\n if (!koaCtx.path.startsWith(prefix)) {\n koaCtx.path = `${prefix}${koaCtx.path}`;\n }\n\n // Set cache-control headers to prevent caching issues during development restarts\n koaCtx.set('Cache-Control', 'no-store, no-cache, must-revalidate, proxy-revalidate');\n koaCtx.set('Pragma', 'no-cache');\n koaCtx.set('Expires', '0');\n koaCtx.set('Surrogate-Control', 'no-store');\n\n vite.middlewares(koaCtx.req, koaCtx.res, (err: unknown) => {\n if (err) {\n reject(err);\n } else {\n if (!koaCtx.res.headersSent) {\n koaCtx.path = originalPath;\n }\n\n resolve(next());\n }\n });\n });\n };\n\n const serveAdmin: Core.MiddlewareHandler = async (koaCtx, next) => {\n await next();\n\n if (koaCtx.method !== 'HEAD' && koaCtx.method !== 'GET') {\n return;\n }\n\n if (koaCtx.body != null || koaCtx.status !== 404) {\n return;\n }\n\n const url = koaCtx.originalUrl;\n\n try {\n let template = await fs.readFile(\n path.relative(ctx.cwd, '.strapi/client/index.html'),\n 'utf-8'\n );\n template = await vite.transformIndexHtml(url, template);\n\n koaCtx.type = 'html';\n koaCtx.body = template;\n } catch (error) {\n ctx.logger.error('Failed to serve admin panel in development mode:', error);\n // Don't fallback to other handlers in development mode to prevent MIME type conflicts\n koaCtx.status = 500;\n koaCtx.body = 'Admin panel temporarily unavailable during server restart';\n }\n };\n\n const adminRoute = `${ctx.adminPath}/:path*`;\n\n // Remove any existing admin routes to prevent conflicts during restart\n const existingRoutes = ctx.strapi.server.router.stack.filter(\n (layer) => layer.path === adminRoute\n );\n existingRoutes.forEach((route) => {\n const index = ctx.strapi.server.router.stack.indexOf(route);\n if (index > -1) {\n ctx.strapi.server.router.stack.splice(index, 1);\n }\n });\n\n ctx.strapi.server.router.get(adminRoute, serveAdmin);\n ctx.strapi.server.router.use(adminRoute, viteMiddlewares);\n\n return {\n async close() {\n await vite.close();\n },\n };\n};\n\nexport { watch };\nexport type { ViteWatcher };\n"],"names":["watch","ctx","finalConfig","mergeConfigWithUserConfig","resolveDevelopmentConfig","logger","debug","createServer","vite","viteMiddlewares","koaCtx","next","Promise","resolve","reject","prefix","basePath","replace","adminPath","originalPath","path","startsWith","set","middlewares","req","res","err","headersSent","serveAdmin","method","body","status","url","originalUrl","template","fs","readFile","relative","cwd","transformIndexHtml","type","error","adminRoute","existingRoutes","strapi","server","router","stack","filter","layer","forEach","route","index","indexOf","splice","get","use","close"],"mappings":";;;;;;;;;;;AAYA,MAAMA,QAAQ,OAAOC,GAAAA,GAAAA;AACnB,IAAA,MAAMC,WAAAA,GAAc,MAAMC,gCAAAA,CAA0B,MAAMC,gCAAyBH,GAAAA,CAAAA,EAAMA,GAAAA,CAAAA;AAEzFA,IAAAA,GAAAA,CAAII,MAAM,CAACC,KAAK,CAAC,aAAA,EAAeJ,WAAAA,CAAAA;AAEhC,IAAA,MAAM,EAAEK,YAAY,EAAE,GAAG,MAAM,OAAO,MAAA,CAAA;IAEtC,MAAMC,IAAAA,GAAO,MAAMD,YAAAA,CAAaL,WAAAA,CAAAA;IAEhC,MAAMO,eAAAA,GAA0C,CAACC,MAAAA,EAAQC,IAAAA,GAAAA;QACvD,OAAO,IAAIC,OAAAA,CAAQ,CAACC,OAAAA,EAASC,MAAAA,GAAAA;AAC3B,YAAA,MAAMC,MAAAA,GAASd,GAAAA,CAAIe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