@kopflos-cms/vite 0.2.0 → 0.2.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.2.2
4
+
5
+ ### Patch Changes
6
+
7
+ - 17ef296: Loading config from the right path
8
+
9
+ ## 0.2.1
10
+
11
+ ### Patch Changes
12
+
13
+ - 46491b5: Relative `configPath` option will be resolved against `basePath` from kopflos environment.
14
+ - 0c33953: Build plugin command now receives `KopflosEnvironment` as argument
15
+
3
16
  ## 0.2.0
4
17
 
5
18
  ### Minor Changes
package/index.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import type { Kopflos, KopflosPlugin } from '@kopflos-cms/core';
1
+ import type { Kopflos, KopflosEnvironment, KopflosPlugin } from '@kopflos-cms/core';
2
2
  import express from 'express';
3
3
  import type { InlineConfig, ViteDevServer } from 'vite';
4
4
  export { defineConfig } from 'vite';
@@ -31,5 +31,5 @@ export default class implements VitePlugin {
31
31
  get viteDevServer(): ViteDevServer | undefined;
32
32
  onStart({ env }: Kopflos): Promise<void> | void;
33
33
  beforeMiddleware(host: express.Router, { env }: Kopflos): Promise<void>;
34
- build(): Promise<void>;
34
+ build(env: KopflosEnvironment): Promise<void>;
35
35
  }
package/index.js CHANGED
@@ -10,15 +10,15 @@ export default class {
10
10
  this.options = options;
11
11
  this.name = '@kopflos-cms/vite';
12
12
  this.outDir = options.outDir || 'dist';
13
- this.rootDir = resolve(process.cwd(), options.root || '');
14
- this.buildDir = resolve(process.cwd(), this.outDir);
13
+ this.rootDir = options.root || '';
14
+ this.buildDir = this.outDir;
15
15
  }
16
16
  get viteDevServer() {
17
17
  return this._viteDevServer;
18
18
  }
19
19
  onStart({ env }) {
20
20
  const viteVars = {
21
- basePath: env.kopflos.config.mode === 'development' ? this.rootDir : this.buildDir,
21
+ basePath: resolve(env.kopflos.basePath, env.kopflos.config.mode === 'development' ? this.rootDir : this.buildDir),
22
22
  };
23
23
  log.info('Variables', viteVars);
24
24
  env.kopflos.variables.VITE = Object.freeze(viteVars);
@@ -26,17 +26,32 @@ export default class {
26
26
  async beforeMiddleware(host, { env }) {
27
27
  if (env.kopflos.config.mode === 'development') {
28
28
  log.info('Development UI mode. Creating Vite server...');
29
- this._viteDevServer = await createViteServer(this.options);
29
+ const configPath = this.options.configPath
30
+ ? resolve(env.kopflos.basePath, this.options.configPath)
31
+ : this.options.configPath;
32
+ this._viteDevServer = await createViteServer({
33
+ ...this.options,
34
+ configPath,
35
+ });
30
36
  host.use(this._viteDevServer.middlewares);
31
37
  }
32
38
  else {
39
+ const buildDir = resolve(env.kopflos.basePath, this.buildDir);
33
40
  log.info('Serving UI from build directory');
34
- log.debug('Build directory:', this.buildDir);
35
- host.use(express.static(this.buildDir));
41
+ log.debug('Build directory:', buildDir);
42
+ host.use(express.static(buildDir));
36
43
  }
37
44
  }
38
- async build() {
45
+ async build(env) {
39
46
  log.info('Building UI...');
40
- await build(await prepareConfig({ outDir: this.outDir, ...this.options }));
47
+ const outDir = resolve(env.kopflos.basePath, this.outDir);
48
+ const configPath = this.options.configPath
49
+ ? resolve(env.kopflos.basePath, this.options.configPath)
50
+ : this.options.configPath;
51
+ await build(await prepareConfig({
52
+ ...this.options,
53
+ outDir,
54
+ configPath,
55
+ }));
41
56
  }
42
57
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kopflos-cms/vite",
3
- "version": "0.2.0",
3
+ "version": "0.2.2",
4
4
  "type": "module",
5
5
  "main": "index.js",
6
6
  "author": "Zazuko GmbH",
@@ -34,7 +34,7 @@
34
34
  "vite": "^6.4.1"
35
35
  },
36
36
  "devDependencies": {
37
- "@kopflos-cms/core": "^0.6.0",
37
+ "@kopflos-cms/core": "^0.6.1",
38
38
  "@zazuko/env-node": "^2.0.0",
39
39
  "@types/glob": "^8.1.0",
40
40
  "chai": "^5.1.1"