Skip to content

Commit

Permalink
chore: expose a vite overwrite option
Browse files Browse the repository at this point in the history
  • Loading branch information
alexandrebodin committed Sep 11, 2024
1 parent e9aa661 commit d0238c2
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 7 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@strapi/pack-up",
"version": "5.0.1-alpha.1",
"version": "5.0.1-alpha.2",
"description": "Simple tools for creating interoperable CJS & ESM packages.",
"keywords": [
"strapi",
Expand Down
8 changes: 7 additions & 1 deletion src/node/core/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import pkgUp from 'pkg-up';
import type { Export } from './exports';
import type { Logger } from './logger';
import type { Runtime } from '../createBuildContext';
import type { PluginOption } from 'vite';
import type { InlineConfig, PluginOption } from 'vite';

interface LoadConfigOptions {
cwd: string;
Expand Down Expand Up @@ -107,6 +107,12 @@ interface ConfigOptions {
* @default tsconfig.build.json
*/
tsconfig?: string;

/**
* @experimental
* @description option to overwrite vite's config
*/
unstable_viteConfig?: InlineConfig;
}

/**
Expand Down
7 changes: 2 additions & 5 deletions src/node/tasks/vite/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
import react from '@vitejs/plugin-react-swc';
import { builtinModules } from 'node:module';
import path from 'path';
import { mergeConfig } from 'vite';

import { resolveConfigProperty } from '../../core/config';

Expand Down Expand Up @@ -52,10 +53,6 @@ const resolveViteConfig = async (ctx: BuildContext, task: ViteBaseTask) => {
emptyOutDir: false,
target: targets[runtime],
outDir,
commonjsOptions: {
include: [/node_modules/, `${ctx.cwd}/**/*`],
extensions: ['.js', '.jsx', '.cjs'],
},
lib: {
entry: entries.map((e) => e.entry),
formats: [format],
Expand Down Expand Up @@ -137,7 +134,7 @@ const resolveViteConfig = async (ctx: BuildContext, task: ViteBaseTask) => {
plugins: [...basePlugins, ...plugins],
} satisfies InlineConfig;

return config;
return mergeConfig(config, ctx.config.unstable_viteConfig ?? {});
};

export { resolveViteConfig };

0 comments on commit d0238c2

Please sign in to comment.