@kopflos-cms/vite 0.3.1 → 0.3.2

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/CHANGELOG.md CHANGED
@@ -1,5 +1,11 @@
1
1
  # @kopflos-cms/vite
2
2
 
3
+ ## 0.3.2
4
+
5
+ ### Patch Changes
6
+
7
+ - fc0e9fb: feat: support per-build config provided by plugins
8
+
3
9
  ## 0.3.1
4
10
 
5
11
  ### Patch Changes
package/index.d.ts CHANGED
@@ -6,6 +6,7 @@ export interface BuildConfiguration {
6
6
  root: string;
7
7
  entrypoints: string[];
8
8
  outDir?: string;
9
+ config?: InlineConfig;
9
10
  }
10
11
  declare module '@kopflos-cms/core' {
11
12
  interface Plugins {
package/index.js CHANGED
@@ -29,12 +29,11 @@ export class VitePlugin {
29
29
  const root = resolve(env.kopflos.basePath, options.root);
30
30
  const outDir = this.resolveOutDir(env, options);
31
31
  return prepareConfig({
32
- ...options,
32
+ entrypoints: options.entrypoints,
33
33
  appRoot: env.kopflos.basePath,
34
34
  root,
35
35
  outDir,
36
- config: vitePlugin.config,
37
- configPath: vitePlugin.configPath,
36
+ config: vitePlugin.config || vitePlugin.configPath,
38
37
  });
39
38
  }
40
39
  resolveOutDir(env, options) {
package/lib/config.d.ts CHANGED
@@ -2,8 +2,8 @@ import type { InlineConfig } from 'vite';
2
2
  import type { BuildConfiguration } from '../index.js';
3
3
  type ConfigOptions = BuildConfiguration & {
4
4
  appRoot: string;
5
- configPath: string | undefined;
6
- config: InlineConfig | undefined;
5
+ config?: InlineConfig | string;
6
+ buildConfig?: InlineConfig;
7
7
  };
8
- export declare function prepareConfig({ appRoot, root, configPath, entrypoints, outDir, config }: ConfigOptions): Promise<Record<string, any>>;
8
+ export declare function prepareConfig({ appRoot, root, entrypoints, outDir, config, buildConfig }: ConfigOptions): Promise<import("vite").UserConfig>;
9
9
  export {};
package/lib/config.js CHANGED
@@ -2,7 +2,7 @@ import { resolve } from 'node:path';
2
2
  import { glob } from 'glob';
3
3
  import { mergeConfig } from 'vite';
4
4
  import defaultConfig from '../vite.config.js';
5
- export async function prepareConfig({ appRoot, root, configPath, entrypoints, outDir, config = {} }) {
5
+ export async function prepareConfig({ appRoot, root, entrypoints, outDir, config = {}, buildConfig = {} }) {
6
6
  const inputConfig = {
7
7
  root,
8
8
  build: {
@@ -17,12 +17,13 @@ export async function prepareConfig({ appRoot, root, configPath, entrypoints, ou
17
17
  input: entrypoints.flatMap(entry => glob.sync(resolve(root, entry))),
18
18
  };
19
19
  }
20
- if (configPath) {
21
- if (configPath.startsWith('.')) {
22
- configPath = resolve(appRoot, configPath);
20
+ let userConfig = config;
21
+ if (typeof config === 'string') {
22
+ if (config.startsWith('.')) {
23
+ config = resolve(appRoot, config);
23
24
  }
24
- const userConfig = await import(configPath);
25
- return mergeConfig(mergeConfig(defaultConfig, inputConfig), userConfig.default);
25
+ userConfig = (await import(config)).default;
26
26
  }
27
- return mergeConfig(config, mergeConfig(defaultConfig, inputConfig));
27
+ return [defaultConfig, inputConfig, config, userConfig, buildConfig]
28
+ .reduce((merged, next) => mergeConfig(merged, next), {});
28
29
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kopflos-cms/vite",
3
- "version": "0.3.1",
3
+ "version": "0.3.2",
4
4
  "type": "module",
5
5
  "main": "index.js",
6
6
  "author": "Zazuko GmbH",