UNPKG

@strapi/strapi

Version:

An open source headless CMS solution to create and manage your own API. It provides a powerful dashboard and features to make your life easier. Databases supported: MySQL, MariaDB, PostgreSQL, SQLite

1 lines 3 kB
{"version":3,"file":"plugins.mjs","sources":["../../../../src/node/vite/plugins.ts"],"sourcesContent":["import type { Plugin } from 'vite';\n\nimport { getDocumentHTML } from '../staticFiles';\nimport type { BuildContext } from '../create-build-context';\n\nconst buildFilesPlugin = (ctx: BuildContext): Plugin => {\n const CHUNK_ID = '.strapi/client/app.js';\n\n return {\n name: 'strapi/server/build-files',\n apply: 'build',\n buildStart() {\n this.emitFile({\n type: 'chunk',\n id: CHUNK_ID,\n name: 'strapi',\n });\n },\n async generateBundle(_options, outputBundle) {\n const bundle = outputBundle;\n const entryFile = Object.values(bundle).find(\n (file) =>\n file.type === 'chunk' && file.name === 'strapi' && file.facadeModuleId?.endsWith(CHUNK_ID)\n );\n\n if (!entryFile) {\n throw new Error(`Failed to find entry file in bundle (${CHUNK_ID})`);\n }\n\n if (entryFile.type !== 'chunk') {\n throw new Error('Entry file is not a chunk');\n }\n\n const entryFileName = entryFile.fileName;\n const entryPath = [ctx.basePath.replace(/\\/+$/, ''), entryFileName].join('/');\n\n this.emitFile({\n type: 'asset',\n fileName: 'index.html',\n source: getDocumentHTML({\n logger: ctx.logger,\n props: {\n entryPath,\n },\n }),\n });\n },\n };\n};\n\nexport { buildFilesPlugin };\n"],"names":["buildFilesPlugin","ctx","CHUNK_ID","name","apply","buildStart","emitFile","type","id","generateBundle","_options","outputBundle","bundle","entryFile","Object","values","find","file","facadeModuleId","endsWith","Error","entryFileName","fileName","entryPath","basePath","replace","join","source","getDocumentHTML","logger","props"],"mappings":";;AAKA,MAAMA,mBAAmB,CAACC,GAAAA,GAAAA;AACxB,IAAA,MAAMC,QAAW,GAAA,uBAAA;IAEjB,OAAO;QACLC,IAAM,EAAA,2BAAA;QACNC,KAAO,EAAA,OAAA;AACPC,QAAAA,UAAAA,CAAAA,GAAAA;YACE,IAAI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