@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 +12 -0
- package/index.d.ts +1 -0
- package/index.js +3 -3
- package/lib/config.d.ts +4 -3
- package/lib/config.js +9 -5
- package/package.json +1 -1
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
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
|
-
|
|
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
|
-
|
|
5
|
-
config
|
|
4
|
+
appRoot: string;
|
|
5
|
+
config?: InlineConfig | string;
|
|
6
|
+
buildConfig?: InlineConfig;
|
|
6
7
|
};
|
|
7
|
-
export declare function prepareConfig({
|
|
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({
|
|
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
|
-
|
|
21
|
-
|
|
22
|
-
|
|
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
|
|
27
|
+
return [defaultConfig, inputConfig, config, userConfig, buildConfig]
|
|
28
|
+
.reduce((merged, next) => mergeConfig(merged, next), {});
|
|
25
29
|
}
|