Skip to content

Commit

Permalink
tested w/ ms-serverlessfuncs
Browse files Browse the repository at this point in the history
  • Loading branch information
asanehisa committed May 13, 2024
1 parent 52ebb40 commit 0f1cd64
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
7 changes: 7 additions & 0 deletions packages/pages/src/vite-plugin/modules/plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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")) {
Expand Down Expand Up @@ -121,6 +127,7 @@ export const buildModules = async (
format: "umd",
entryFileNames: `${moduleName}.umd.js`,
},
...rollupOptions,
},
reportCompressedSize: false,
},
Expand Down
7 changes: 7 additions & 0 deletions packages/pages/src/vite-plugin/serverless-functions/plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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")) {
Expand Down Expand Up @@ -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,
},
Expand Down

0 comments on commit 0f1cd64

Please sign in to comment.