@kopflos-cms/vite 0.1.0 → 0.1.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,18 @@
1
1
  # @kopflos-cms/vite
2
2
 
3
+ ## 0.1.2
4
+
5
+ ### Patch Changes
6
+
7
+ - 175c538: Add inline `config` to plugin config
8
+ - 3370532: Plugins are now implemented as classes
9
+
10
+ ## 0.1.1
11
+
12
+ ### Patch Changes
13
+
14
+ - aef55d4: build(deps): bump vite from 6.0.7 to 6.0.9
15
+
3
16
  ## 0.1.0
4
17
 
5
18
  ### Minor Changes
package/index.d.ts CHANGED
@@ -1,7 +1,9 @@
1
- import type { KopflosPlugin } from '@kopflos-cms/core';
1
+ import type { KopflosPluginConstructor } from '@kopflos-cms/core';
2
+ import type { InlineConfig } from 'vite';
2
3
  export { defineConfig } from 'vite';
3
4
  export interface Options {
4
5
  configPath?: string;
6
+ config?: InlineConfig;
5
7
  root?: string;
6
8
  outDir?: string;
7
9
  entrypoints?: string[];
@@ -11,4 +13,4 @@ declare module '@kopflos-cms/core' {
11
13
  '@kopflos-cms/vite'?: Options;
12
14
  }
13
15
  }
14
- export default function ({ outDir, ...options }: Options): KopflosPlugin;
16
+ export default function ({ outDir, ...options }: Options): KopflosPluginConstructor;
package/index.js CHANGED
@@ -8,16 +8,19 @@ export { defineConfig } from 'vite';
8
8
  export default function ({ outDir = 'dist', ...options }) {
9
9
  const rootDir = resolve(process.cwd(), options.root || '');
10
10
  const buildDir = resolve(process.cwd(), outDir);
11
- return {
12
- onStart({ env }) {
11
+ return class {
12
+ constructor(instance) {
13
+ this.env = instance.env;
14
+ }
15
+ onStart() {
13
16
  const viteVars = {
14
- basePath: env.kopflos.config.mode === 'development' ? rootDir : buildDir,
17
+ basePath: this.env.kopflos.config.mode === 'development' ? rootDir : buildDir,
15
18
  };
16
19
  log.info('Variables', viteVars);
17
- env.kopflos.variables.VITE = Object.freeze(viteVars);
18
- },
19
- async beforeMiddleware(host, { env }) {
20
- if (env.kopflos.config.mode === 'development') {
20
+ this.env.kopflos.variables.VITE = Object.freeze(viteVars);
21
+ }
22
+ async beforeMiddleware(host) {
23
+ if (this.env.kopflos.config.mode === 'development') {
21
24
  log.info('Development UI mode. Creating Vite server...');
22
25
  const viteServer = await createViteServer(options);
23
26
  host.use(viteServer.middlewares);
@@ -27,10 +30,10 @@ export default function ({ outDir = 'dist', ...options }) {
27
30
  log.debug('Build directory:', buildDir);
28
31
  host.use(express.static(buildDir));
29
32
  }
30
- },
31
- async build() {
33
+ }
34
+ static async build() {
32
35
  log.info('Building UI...');
33
36
  await build(await prepareConfig({ outDir, ...options }));
34
- },
37
+ }
35
38
  };
36
39
  }
package/lib/config.d.ts CHANGED
@@ -1,2 +1,2 @@
1
1
  import type { Options } from '../index.js';
2
- export declare function prepareConfig({ root, configPath, entrypoints, outDir }: Omit<Options, 'mode'>): Promise<Record<string, any>>;
2
+ export declare function prepareConfig({ root, configPath, entrypoints, outDir, config }: Omit<Options, 'mode'>): Promise<Record<string, any>>;
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 }) {
5
+ export async function prepareConfig({ root, configPath, entrypoints, outDir, config = {} }) {
6
6
  const inputConfig = {
7
7
  root,
8
8
  build: {
@@ -21,5 +21,5 @@ export async function prepareConfig({ root, configPath, entrypoints, outDir }) {
21
21
  const userConfig = await import(configPath);
22
22
  return mergeConfig(mergeConfig(defaultConfig, inputConfig), userConfig.default);
23
23
  }
24
- return mergeConfig(defaultConfig, inputConfig);
24
+ return mergeConfig(config, mergeConfig(defaultConfig, inputConfig));
25
25
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kopflos-cms/vite",
3
- "version": "0.1.0",
3
+ "version": "0.1.2",
4
4
  "type": "module",
5
5
  "main": "index.js",
6
6
  "author": "Zazuko GmbH",
@@ -31,7 +31,7 @@
31
31
  "express": "^5.0.1",
32
32
  "glob": "^11.0.0",
33
33
  "onetime": "^7.0.0",
34
- "vite": "^6.0.7"
34
+ "vite": "^6.0.9"
35
35
  },
36
36
  "devDependencies": {
37
37
  "@types/glob": "^8.1.0",