diff --git a/packages/pages/src/vite-plugin/modules/plugin.ts b/packages/pages/src/vite-plugin/modules/plugin.ts index 7035fb061..edd1ae651 100644 --- a/packages/pages/src/vite-plugin/modules/plugin.ts +++ b/packages/pages/src/vite-plugin/modules/plugin.ts @@ -15,6 +15,7 @@ import postcss from "postcss"; import nested from "postcss-nested"; import { createModuleLogger } from "../../common/src/module/internal/logger.js"; import { getModuleName } from "../../common/src/module/internal/getModuleConfig.js"; +import { scopedViteConfigPath } from "../../util/viteConfig.js"; type FileInfo = { path: string; @@ -61,6 +62,11 @@ export const buildModules = async ( ); } + const viteConfig = await import( + scopedViteConfigPath(projectStructure.config.scope) ?? "" + ); + const rollupOptions = viteConfig?.default?.build?.rollupOptions; + for (const [moduleName, fileInfo] of Object.entries(filepaths)) { logger.info = (msg, options) => { if (msg.includes("building for production")) { @@ -121,6 +127,7 @@ export const buildModules = async ( format: "umd", entryFileNames: `${moduleName}.umd.js`, }, + ...rollupOptions, }, reportCompressedSize: false, }, diff --git a/packages/pages/src/vite-plugin/serverless-functions/plugin.ts b/packages/pages/src/vite-plugin/serverless-functions/plugin.ts index 7c1d7da45..66e245c79 100644 --- a/packages/pages/src/vite-plugin/serverless-functions/plugin.ts +++ b/packages/pages/src/vite-plugin/serverless-functions/plugin.ts @@ -8,6 +8,7 @@ import { processEnvVariables } from "../../util/processEnvVariables.js"; import { FunctionMetadataParser } from "../../common/src/function/internal/functionMetadataParser.js"; import { nodePolyfills } from "vite-plugin-node-polyfills"; import pc from "picocolors"; +import { scopedViteConfigPath } from "../../util/viteConfig.js"; export const buildServerlessFunctions = async ( projectStructure: ProjectStructure @@ -41,6 +42,11 @@ export const buildServerlessFunctions = async ( const logger = createLogger(); const loggerInfo = logger.info; + const viteConfig = await import( + scopedViteConfigPath(projectStructure.config.scope) ?? "" + ); + const rollupOptions = viteConfig?.default?.build?.rollupOptions; + for (const [name, filepath] of Object.entries(filepaths)) { logger.info = (msg, options) => { if (msg.includes("building for production")) { @@ -75,6 +81,7 @@ export const buildServerlessFunctions = async ( // must use this over lib.fileName otherwise it always ends in .js entryFileNames: `[name]/mod.ts`, }, + ...rollupOptions, }, reportCompressedSize: false, },