@kopflos-cms/vite 0.3.0 → 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,17 @@
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
+
9
+ ## 0.3.1
10
+
11
+ ### Patch Changes
12
+
13
+ - 5ca6fa4: Resolve `configPath` against the kopflos' base path
14
+
3
15
  ## 0.3.0
4
16
 
5
17
  ### Minor 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,11 +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
+ appRoot: env.kopflos.basePath,
33
34
  root,
34
35
  outDir,
35
- config: vitePlugin.config,
36
- configPath: vitePlugin.configPath,
36
+ config: vitePlugin.config || vitePlugin.configPath,
37
37
  });
38
38
  }
39
39
  resolveOutDir(env, options) {
package/lib/config.d.ts CHANGED
@@ -1,8 +1,9 @@
1
1
  import type { InlineConfig } from 'vite';
2
2
  import type { BuildConfiguration } from '../index.js';
3
3
  type ConfigOptions = BuildConfiguration & {
4
- configPath: string | undefined;
5
- config: InlineConfig | undefined;
4
+ appRoot: string;
5
+ config?: InlineConfig | string;
6
+ buildConfig?: InlineConfig;
6
7
  };
7
- export declare function prepareConfig({ 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>;
8
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({ 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,9 +17,13 @@ export async function prepareConfig({ root, configPath, entrypoints, outDir, con
17
17
  input: entrypoints.flatMap(entry => glob.sync(resolve(root, entry))),
18
18
  };
19
19
  }
20
- if (configPath) {
21
- const userConfig = await import(configPath);
22
- return mergeConfig(mergeConfig(defaultConfig, inputConfig), userConfig.default);
20
+ let userConfig = config;
21
+ if (typeof config === 'string') {
22
+ if (config.startsWith('.')) {
23
+ config = resolve(appRoot, config);
24
+ }
25
+ userConfig = (await import(config)).default;
23
26
  }
24
- return mergeConfig(config, mergeConfig(defaultConfig, inputConfig));
27
+ return [defaultConfig, inputConfig, config, userConfig, buildConfig]
28
+ .reduce((merged, next) => mergeConfig(merged, next), {});
25
29
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kopflos-cms/vite",
3
- "version": "0.3.0",
3
+ "version": "0.3.2",
4
4
  "type": "module",
5
5
  "main": "index.js",
6
6
  "author": "Zazuko GmbH",