@vixt/core 0.1.18 → 0.1.19
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/dist/client/index.d.mts +3 -3
- package/dist/client/index.d.ts +3 -3
- package/dist/index.d.mts +31 -70
- package/dist/index.d.ts +31 -70
- package/dist/index.mjs +24 -198
- package/dist/shared/{core.3b42a3cd.d.mts → core.b103189b.d.mts} +2 -2
- package/dist/shared/{core.3b42a3cd.d.ts → core.b103189b.d.ts} +2 -2
- package/package.json +1 -1
package/dist/client/index.d.mts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
+
import { f as VixtAppConfig } from '../shared/core.b103189b.mjs';
|
|
2
|
+
import { Pinia } from 'pinia';
|
|
1
3
|
import { App, Plugin } from 'vue';
|
|
2
4
|
import { Router, RouteRecord } from 'vue-router';
|
|
3
|
-
import { Pinia } from 'pinia';
|
|
4
|
-
import { f as VixtAppConfig } from '../shared/core.3b42a3cd.mjs';
|
|
5
|
-
import 'vite';
|
|
6
5
|
import 'c12';
|
|
6
|
+
import 'vite';
|
|
7
7
|
|
|
8
8
|
interface VixtApp {
|
|
9
9
|
app: App;
|
package/dist/client/index.d.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
+
import { f as VixtAppConfig } from '../shared/core.b103189b.js';
|
|
2
|
+
import { Pinia } from 'pinia';
|
|
1
3
|
import { App, Plugin } from 'vue';
|
|
2
4
|
import { Router, RouteRecord } from 'vue-router';
|
|
3
|
-
import { Pinia } from 'pinia';
|
|
4
|
-
import { f as VixtAppConfig } from '../shared/core.3b42a3cd.js';
|
|
5
|
-
import 'vite';
|
|
6
5
|
import 'c12';
|
|
6
|
+
import 'vite';
|
|
7
7
|
|
|
8
8
|
interface VixtApp {
|
|
9
9
|
app: App;
|
package/dist/index.d.mts
CHANGED
|
@@ -1,77 +1,13 @@
|
|
|
1
|
-
import { V as Vixt, a as VixtModule, M as ModuleOptions, b as VixtOptions, c as VixtConfigLayer, d as VixtConfigLayerMeta, e as ModuleDefinition } from './shared/core.3b42a3cd.mjs';
|
|
2
|
-
export { g as ModuleMeta, P as PluginOptions, f as VixtAppConfig } from './shared/core.3b42a3cd.mjs';
|
|
3
|
-
import { TSConfig } from 'pkg-types';
|
|
4
|
-
import { RawVueCompilerOptions } from '@vue/language-core';
|
|
5
|
-
import Checker from 'vite-plugin-checker';
|
|
6
1
|
import * as c12 from 'c12';
|
|
7
2
|
import { LoadConfigOptions } from 'c12';
|
|
3
|
+
import { V as VixtOptions, a as VixtConfigLayer, b as VixtConfigLayerMeta, M as ModuleOptions, c as ModuleDefinition, d as VixtModule, e as Vixt } from './shared/core.b103189b.mjs';
|
|
4
|
+
export { g as ModuleMeta, P as PluginOptions, f as VixtAppConfig } from './shared/core.b103189b.mjs';
|
|
5
|
+
import { RawVueCompilerOptions } from '@vue/language-core';
|
|
6
|
+
import { TSConfig } from 'pkg-types';
|
|
7
|
+
import Checker from 'vite-plugin-checker';
|
|
8
8
|
import * as vite from 'vite';
|
|
9
9
|
import { PluginOption } from 'vite';
|
|
10
10
|
|
|
11
|
-
declare module '@vixt/core' {
|
|
12
|
-
interface VixtOptions {
|
|
13
|
-
app?: AppOptions;
|
|
14
|
-
}
|
|
15
|
-
}
|
|
16
|
-
type Property = Record<string, string>;
|
|
17
|
-
interface AppHead {
|
|
18
|
-
meta?: Property[];
|
|
19
|
-
link?: Property[];
|
|
20
|
-
style?: Property[];
|
|
21
|
-
script?: Property[];
|
|
22
|
-
title?: Property[];
|
|
23
|
-
noscript?: Property[];
|
|
24
|
-
}
|
|
25
|
-
interface AppOptions {
|
|
26
|
-
head?: AppHead;
|
|
27
|
-
/**
|
|
28
|
-
* @default /
|
|
29
|
-
*/
|
|
30
|
-
baseURL?: string;
|
|
31
|
-
/**
|
|
32
|
-
* @default 'app'
|
|
33
|
-
*/
|
|
34
|
-
rootId?: string;
|
|
35
|
-
/**
|
|
36
|
-
* @default 'div'
|
|
37
|
-
*/
|
|
38
|
-
rootTag?: string;
|
|
39
|
-
/** inject css files */
|
|
40
|
-
css?: string[];
|
|
41
|
-
/**
|
|
42
|
-
* @default './loading.html'
|
|
43
|
-
*/
|
|
44
|
-
loadingTemplate?: string;
|
|
45
|
-
/** transform main.ts */
|
|
46
|
-
transformMain?: (code: string, vixt: Vixt) => string | undefined;
|
|
47
|
-
}
|
|
48
|
-
declare const app: VixtModule<AppOptions>;
|
|
49
|
-
|
|
50
|
-
declare const config: VixtModule<ModuleOptions>;
|
|
51
|
-
|
|
52
|
-
declare module '@vixt/core' {
|
|
53
|
-
interface VixtOptions {
|
|
54
|
-
typescript?: TypescriptOptions;
|
|
55
|
-
}
|
|
56
|
-
}
|
|
57
|
-
interface TypescriptOptions {
|
|
58
|
-
references?: (string | {
|
|
59
|
-
path?: string;
|
|
60
|
-
content?: string;
|
|
61
|
-
})[];
|
|
62
|
-
tsConfig?: TSConfig & {
|
|
63
|
-
vueCompilerOptions?: RawVueCompilerOptions;
|
|
64
|
-
};
|
|
65
|
-
/** https://github.com/fi3ework/vite-plugin-checker */
|
|
66
|
-
typeCheck?: Parameters<typeof Checker>[0];
|
|
67
|
-
/**
|
|
68
|
-
* Generate a `*.vue` shim
|
|
69
|
-
* @default false
|
|
70
|
-
*/
|
|
71
|
-
shim?: boolean;
|
|
72
|
-
}
|
|
73
|
-
declare const typescript: VixtModule<TypescriptOptions>;
|
|
74
|
-
|
|
75
11
|
declare function defineVixtConfig(input: VixtOptions): VixtOptions;
|
|
76
12
|
declare function loadVixtConfig(opts?: LoadConfigOptions<VixtOptions>): Promise<c12.ResolvedConfig<VixtOptions, c12.ConfigLayerMeta>>;
|
|
77
13
|
declare function applyLayers(layers: VixtConfigLayer[], config: VixtOptions): {
|
|
@@ -99,7 +35,32 @@ declare function defineVixtModule<T extends ModuleOptions>(definition: ModuleDef
|
|
|
99
35
|
declare function installModule(module: VixtModule, inlineOptions: any, vixt: Vixt): PluginOption;
|
|
100
36
|
declare function applyLayerModules(layers: VixtConfigLayer[], config: VixtOptions): Promise<VixtModule[]>;
|
|
101
37
|
|
|
38
|
+
declare const config: VixtModule<ModuleOptions>;
|
|
39
|
+
|
|
40
|
+
declare module '@vixt/core' {
|
|
41
|
+
interface VixtOptions {
|
|
42
|
+
typescript?: TypescriptOptions;
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
interface TypescriptOptions {
|
|
46
|
+
references?: (string | {
|
|
47
|
+
path?: string;
|
|
48
|
+
content?: string;
|
|
49
|
+
})[];
|
|
50
|
+
tsConfig?: TSConfig & {
|
|
51
|
+
vueCompilerOptions?: RawVueCompilerOptions;
|
|
52
|
+
};
|
|
53
|
+
/** https://github.com/fi3ework/vite-plugin-checker */
|
|
54
|
+
typeCheck?: Parameters<typeof Checker>[0];
|
|
55
|
+
/**
|
|
56
|
+
* Generate a `*.vue` shim
|
|
57
|
+
* @default false
|
|
58
|
+
*/
|
|
59
|
+
shim?: boolean;
|
|
60
|
+
}
|
|
61
|
+
declare const typescript: VixtModule<TypescriptOptions>;
|
|
62
|
+
|
|
102
63
|
declare function loadVixt(opts?: LoadConfigOptions<VixtOptions>): Promise<Vixt>;
|
|
103
64
|
declare function createVixtPlugin(loadOptions: LoadConfigOptions<VixtOptions>): (options?: VixtOptions | undefined) => vite.PluginOption;
|
|
104
65
|
|
|
105
|
-
export {
|
|
66
|
+
export { ModuleDefinition, ModuleOptions, type TypescriptOptions, Vixt, VixtConfigLayer, VixtConfigLayerMeta, VixtModule, type VixtOptions, applyLayerModules, applyLayers, config, createVixtPlugin, defineVitePlugin, defineVixtConfig, defineVixtModule, installModule, isSamePath, loadEnv, loadVixt, loadVixtConfig, loadWorkspaceEnv, resolveLayersDirs, typescript };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,77 +1,13 @@
|
|
|
1
|
-
import { V as Vixt, a as VixtModule, M as ModuleOptions, b as VixtOptions, c as VixtConfigLayer, d as VixtConfigLayerMeta, e as ModuleDefinition } from './shared/core.3b42a3cd.js';
|
|
2
|
-
export { g as ModuleMeta, P as PluginOptions, f as VixtAppConfig } from './shared/core.3b42a3cd.js';
|
|
3
|
-
import { TSConfig } from 'pkg-types';
|
|
4
|
-
import { RawVueCompilerOptions } from '@vue/language-core';
|
|
5
|
-
import Checker from 'vite-plugin-checker';
|
|
6
1
|
import * as c12 from 'c12';
|
|
7
2
|
import { LoadConfigOptions } from 'c12';
|
|
3
|
+
import { V as VixtOptions, a as VixtConfigLayer, b as VixtConfigLayerMeta, M as ModuleOptions, c as ModuleDefinition, d as VixtModule, e as Vixt } from './shared/core.b103189b.js';
|
|
4
|
+
export { g as ModuleMeta, P as PluginOptions, f as VixtAppConfig } from './shared/core.b103189b.js';
|
|
5
|
+
import { RawVueCompilerOptions } from '@vue/language-core';
|
|
6
|
+
import { TSConfig } from 'pkg-types';
|
|
7
|
+
import Checker from 'vite-plugin-checker';
|
|
8
8
|
import * as vite from 'vite';
|
|
9
9
|
import { PluginOption } from 'vite';
|
|
10
10
|
|
|
11
|
-
declare module '@vixt/core' {
|
|
12
|
-
interface VixtOptions {
|
|
13
|
-
app?: AppOptions;
|
|
14
|
-
}
|
|
15
|
-
}
|
|
16
|
-
type Property = Record<string, string>;
|
|
17
|
-
interface AppHead {
|
|
18
|
-
meta?: Property[];
|
|
19
|
-
link?: Property[];
|
|
20
|
-
style?: Property[];
|
|
21
|
-
script?: Property[];
|
|
22
|
-
title?: Property[];
|
|
23
|
-
noscript?: Property[];
|
|
24
|
-
}
|
|
25
|
-
interface AppOptions {
|
|
26
|
-
head?: AppHead;
|
|
27
|
-
/**
|
|
28
|
-
* @default /
|
|
29
|
-
*/
|
|
30
|
-
baseURL?: string;
|
|
31
|
-
/**
|
|
32
|
-
* @default 'app'
|
|
33
|
-
*/
|
|
34
|
-
rootId?: string;
|
|
35
|
-
/**
|
|
36
|
-
* @default 'div'
|
|
37
|
-
*/
|
|
38
|
-
rootTag?: string;
|
|
39
|
-
/** inject css files */
|
|
40
|
-
css?: string[];
|
|
41
|
-
/**
|
|
42
|
-
* @default './loading.html'
|
|
43
|
-
*/
|
|
44
|
-
loadingTemplate?: string;
|
|
45
|
-
/** transform main.ts */
|
|
46
|
-
transformMain?: (code: string, vixt: Vixt) => string | undefined;
|
|
47
|
-
}
|
|
48
|
-
declare const app: VixtModule<AppOptions>;
|
|
49
|
-
|
|
50
|
-
declare const config: VixtModule<ModuleOptions>;
|
|
51
|
-
|
|
52
|
-
declare module '@vixt/core' {
|
|
53
|
-
interface VixtOptions {
|
|
54
|
-
typescript?: TypescriptOptions;
|
|
55
|
-
}
|
|
56
|
-
}
|
|
57
|
-
interface TypescriptOptions {
|
|
58
|
-
references?: (string | {
|
|
59
|
-
path?: string;
|
|
60
|
-
content?: string;
|
|
61
|
-
})[];
|
|
62
|
-
tsConfig?: TSConfig & {
|
|
63
|
-
vueCompilerOptions?: RawVueCompilerOptions;
|
|
64
|
-
};
|
|
65
|
-
/** https://github.com/fi3ework/vite-plugin-checker */
|
|
66
|
-
typeCheck?: Parameters<typeof Checker>[0];
|
|
67
|
-
/**
|
|
68
|
-
* Generate a `*.vue` shim
|
|
69
|
-
* @default false
|
|
70
|
-
*/
|
|
71
|
-
shim?: boolean;
|
|
72
|
-
}
|
|
73
|
-
declare const typescript: VixtModule<TypescriptOptions>;
|
|
74
|
-
|
|
75
11
|
declare function defineVixtConfig(input: VixtOptions): VixtOptions;
|
|
76
12
|
declare function loadVixtConfig(opts?: LoadConfigOptions<VixtOptions>): Promise<c12.ResolvedConfig<VixtOptions, c12.ConfigLayerMeta>>;
|
|
77
13
|
declare function applyLayers(layers: VixtConfigLayer[], config: VixtOptions): {
|
|
@@ -99,7 +35,32 @@ declare function defineVixtModule<T extends ModuleOptions>(definition: ModuleDef
|
|
|
99
35
|
declare function installModule(module: VixtModule, inlineOptions: any, vixt: Vixt): PluginOption;
|
|
100
36
|
declare function applyLayerModules(layers: VixtConfigLayer[], config: VixtOptions): Promise<VixtModule[]>;
|
|
101
37
|
|
|
38
|
+
declare const config: VixtModule<ModuleOptions>;
|
|
39
|
+
|
|
40
|
+
declare module '@vixt/core' {
|
|
41
|
+
interface VixtOptions {
|
|
42
|
+
typescript?: TypescriptOptions;
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
interface TypescriptOptions {
|
|
46
|
+
references?: (string | {
|
|
47
|
+
path?: string;
|
|
48
|
+
content?: string;
|
|
49
|
+
})[];
|
|
50
|
+
tsConfig?: TSConfig & {
|
|
51
|
+
vueCompilerOptions?: RawVueCompilerOptions;
|
|
52
|
+
};
|
|
53
|
+
/** https://github.com/fi3ework/vite-plugin-checker */
|
|
54
|
+
typeCheck?: Parameters<typeof Checker>[0];
|
|
55
|
+
/**
|
|
56
|
+
* Generate a `*.vue` shim
|
|
57
|
+
* @default false
|
|
58
|
+
*/
|
|
59
|
+
shim?: boolean;
|
|
60
|
+
}
|
|
61
|
+
declare const typescript: VixtModule<TypescriptOptions>;
|
|
62
|
+
|
|
102
63
|
declare function loadVixt(opts?: LoadConfigOptions<VixtOptions>): Promise<Vixt>;
|
|
103
64
|
declare function createVixtPlugin(loadOptions: LoadConfigOptions<VixtOptions>): (options?: VixtOptions | undefined) => vite.PluginOption;
|
|
104
65
|
|
|
105
|
-
export {
|
|
66
|
+
export { ModuleDefinition, ModuleOptions, type TypescriptOptions, Vixt, VixtConfigLayer, VixtConfigLayerMeta, VixtModule, type VixtOptions, applyLayerModules, applyLayers, config, createVixtPlugin, defineVitePlugin, defineVixtConfig, defineVixtModule, installModule, isSamePath, loadEnv, loadVixt, loadVixtConfig, loadWorkspaceEnv, resolveLayersDirs, typescript };
|
package/dist/index.mjs
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
import path from 'pathe';
|
|
2
|
-
import fs from 'fs-extra';
|
|
3
|
-
import 'tsx/esm';
|
|
4
|
-
import { pathToFileURL } from 'mlly';
|
|
5
|
-
import defu from 'defu';
|
|
6
1
|
import { cwd, env } from 'node:process';
|
|
7
2
|
import { loadConfig } from 'c12';
|
|
8
|
-
import
|
|
3
|
+
import fs from 'fs-extra';
|
|
4
|
+
import path from 'pathe';
|
|
9
5
|
import { cac } from 'cac';
|
|
10
6
|
import { findUpSync } from 'find-up';
|
|
7
|
+
import { loadEnv as loadEnv$1 } from 'vite';
|
|
8
|
+
import defu from 'defu';
|
|
9
|
+
import { pathToFileURL } from 'mlly';
|
|
10
|
+
import 'tsx/esm';
|
|
11
11
|
import Checker from 'vite-plugin-checker';
|
|
12
12
|
|
|
13
13
|
function defineVixtConfig(input) {
|
|
@@ -80,6 +80,22 @@ function resolveLayersDirs(layers = [], config) {
|
|
|
80
80
|
return dirs;
|
|
81
81
|
}
|
|
82
82
|
|
|
83
|
+
function loadEnv(mode, envDir, prefixes) {
|
|
84
|
+
const parsedArgv = cac().parse();
|
|
85
|
+
mode = mode || parsedArgv.options.mode || parsedArgv.options.m || env.NODE_ENV;
|
|
86
|
+
return {
|
|
87
|
+
MODE: mode,
|
|
88
|
+
DEV: env.NODE_ENV !== "production",
|
|
89
|
+
PROD: env.NODE_ENV === "production",
|
|
90
|
+
...loadWorkspaceEnv(mode, prefixes),
|
|
91
|
+
...loadEnv$1(mode, envDir || cwd(), prefixes)
|
|
92
|
+
};
|
|
93
|
+
}
|
|
94
|
+
function loadWorkspaceEnv(mode, prefixes) {
|
|
95
|
+
const workspaceManifestLocation = findUpSync(["pnpm-workspace.yaml", "pnpm-workspace.yml"]);
|
|
96
|
+
return workspaceManifestLocation ? loadEnv$1(mode, path.dirname(workspaceManifestLocation), prefixes) : {};
|
|
97
|
+
}
|
|
98
|
+
|
|
83
99
|
function defineVitePlugin(pluginFn) {
|
|
84
100
|
return pluginFn;
|
|
85
101
|
}
|
|
@@ -125,196 +141,6 @@ async function applyLayerModules(layers, config) {
|
|
|
125
141
|
return modules;
|
|
126
142
|
}
|
|
127
143
|
|
|
128
|
-
function resolveHeadTag(tag, attrs) {
|
|
129
|
-
const attrsStr = Object.entries(attrs).filter(([k]) => k !== "children").map(([k, v]) => `${k}="${v}"`).join(" ");
|
|
130
|
-
return attrs?.children ? `<${tag} ${attrsStr}>${attrs.children}</${tag}>` : `<${tag} ${attrsStr} />`;
|
|
131
|
-
}
|
|
132
|
-
function generateIndexHtml(options, vixt) {
|
|
133
|
-
const { buildDir, buildDirName, rootDir } = vixt.options;
|
|
134
|
-
const indexHtmlPath = path.resolve(rootDir, "index.html");
|
|
135
|
-
if (!fs.existsSync(indexHtmlPath))
|
|
136
|
-
fs.outputFileSync(indexHtmlPath, `<!-- Generated by Vixt -->
|
|
137
|
-
<!-- This file transform from '${buildDirName}/index.html' -->
|
|
138
|
-
`);
|
|
139
|
-
const { head = {}, rootTag, rootId } = options;
|
|
140
|
-
const headTemplate = Object.entries(head).filter(([k]) => k !== "noscript").map(([tag, attrs]) => attrs.map((e) => resolveHeadTag(tag, e))).flat().join("\n");
|
|
141
|
-
const noscriptTemplate = Object.entries(head).filter(([k]) => k === "noscript").map(([tag, attrs]) => attrs.map((e) => resolveHeadTag(tag, e))).flat().join("\n");
|
|
142
|
-
let { loadingTemplate = "" } = options;
|
|
143
|
-
if (!loadingTemplate) {
|
|
144
|
-
for (const layer of vixt._layers) {
|
|
145
|
-
const loadingTemplatePath = path.resolve(layer.cwd, "loading.html");
|
|
146
|
-
if (fs.existsSync(loadingTemplatePath)) {
|
|
147
|
-
loadingTemplate = fs.readFileSync(loadingTemplatePath, "utf-8");
|
|
148
|
-
break;
|
|
149
|
-
}
|
|
150
|
-
}
|
|
151
|
-
}
|
|
152
|
-
const code = `<!DOCTYPE html>
|
|
153
|
-
<html>
|
|
154
|
-
<head>
|
|
155
|
-
${headTemplate}
|
|
156
|
-
</head>
|
|
157
|
-
<body>
|
|
158
|
-
<${rootTag} id="${rootId}">
|
|
159
|
-
${loadingTemplate}
|
|
160
|
-
</${rootTag}>
|
|
161
|
-
<script type="module" src="/src/main.ts"><\/script>
|
|
162
|
-
${noscriptTemplate}
|
|
163
|
-
</body>
|
|
164
|
-
</html>
|
|
165
|
-
`;
|
|
166
|
-
fs.outputFileSync(path.resolve(buildDir, "index.html"), code);
|
|
167
|
-
return code;
|
|
168
|
-
}
|
|
169
|
-
function generateAppConfig(vixt) {
|
|
170
|
-
const { buildImportsDir, srcDir, srcDirName } = vixt.options;
|
|
171
|
-
let appConfigsImportTemplate = "";
|
|
172
|
-
let appConfigsMergeTemplate = "";
|
|
173
|
-
let i = 0;
|
|
174
|
-
for (const layer of vixt._layers) {
|
|
175
|
-
const appConfigPath = path.resolve(layer.cwd, srcDirName, "app.config.ts");
|
|
176
|
-
if (fs.existsSync(appConfigPath)) {
|
|
177
|
-
const appConfigName = `__app_config_${i}`;
|
|
178
|
-
appConfigsImportTemplate += `import ${appConfigName} from '${appConfigPath}'
|
|
179
|
-
`;
|
|
180
|
-
appConfigsMergeTemplate += `${appConfigName}, `;
|
|
181
|
-
i++;
|
|
182
|
-
}
|
|
183
|
-
}
|
|
184
|
-
const appConfigTemplate = `
|
|
185
|
-
import { defu } from 'defu'
|
|
186
|
-
${appConfigsImportTemplate}
|
|
187
|
-
const appConfig = defu(${appConfigsMergeTemplate}{})
|
|
188
|
-
function useAppConfig() {
|
|
189
|
-
return appConfig
|
|
190
|
-
}
|
|
191
|
-
export { useAppConfig }
|
|
192
|
-
`;
|
|
193
|
-
const mainTsPath = path.resolve(srcDir, "main.ts");
|
|
194
|
-
fs.outputFileSync(path.resolve(buildImportsDir, `app.config.ts`), `// @ts-nocheck
|
|
195
|
-
export { useAppConfig } from '${mainTsPath}'`);
|
|
196
|
-
return appConfigTemplate;
|
|
197
|
-
}
|
|
198
|
-
function generatePlugins(vixt) {
|
|
199
|
-
const { srcDirName } = vixt.options;
|
|
200
|
-
let pluginsImportTemplate = "";
|
|
201
|
-
let pluginsMergeTemplate = "";
|
|
202
|
-
let i = 0;
|
|
203
|
-
for (const layer of [...vixt._layers].reverse()) {
|
|
204
|
-
const pluginsDir = path.resolve(layer.cwd, srcDirName, "plugins");
|
|
205
|
-
const files = fs.existsSync(pluginsDir) ? fs.readdirSync(pluginsDir) : [];
|
|
206
|
-
for (const f of files) {
|
|
207
|
-
const p = path.resolve(pluginsDir, f);
|
|
208
|
-
const pluginName = `__plugin_${i}`;
|
|
209
|
-
pluginsImportTemplate += `import ${pluginName} from '${p}'
|
|
210
|
-
`;
|
|
211
|
-
pluginsMergeTemplate += `${pluginName}, `;
|
|
212
|
-
i++;
|
|
213
|
-
}
|
|
214
|
-
}
|
|
215
|
-
const pluginsTemplate = `
|
|
216
|
-
${pluginsImportTemplate}
|
|
217
|
-
const plugins = [${pluginsMergeTemplate}]
|
|
218
|
-
function usePlugins(options) {
|
|
219
|
-
for (const plugin of plugins) {
|
|
220
|
-
typeof plugin === 'function' && plugin(options)
|
|
221
|
-
}
|
|
222
|
-
}
|
|
223
|
-
`;
|
|
224
|
-
return pluginsTemplate;
|
|
225
|
-
}
|
|
226
|
-
function getAppComponentPath(vixt) {
|
|
227
|
-
const { srcDirName } = vixt.options;
|
|
228
|
-
for (const layer of vixt._layers) {
|
|
229
|
-
const appComponentPath = path.resolve(layer.cwd, srcDirName, "App.vue");
|
|
230
|
-
if (fs.existsSync(appComponentPath))
|
|
231
|
-
return appComponentPath;
|
|
232
|
-
}
|
|
233
|
-
}
|
|
234
|
-
function generateMainTs(options, vixt) {
|
|
235
|
-
const { buildDir, buildDirName, srcDir } = vixt.options;
|
|
236
|
-
const mainTsPath = path.resolve(srcDir, "main.ts");
|
|
237
|
-
if (!fs.existsSync(mainTsPath))
|
|
238
|
-
fs.outputFileSync(mainTsPath, `// Generated by Vixt
|
|
239
|
-
// This file transform from '${buildDirName}/main.ts'
|
|
240
|
-
`);
|
|
241
|
-
const appComponentPath = getAppComponentPath(vixt) || "@vixt/core/client/App.vue";
|
|
242
|
-
const appComponentTemplate = `import App from '${appComponentPath}'`;
|
|
243
|
-
const cssTemplate = options?.css?.map((css) => `import '${css}'`).join("\n") ?? "";
|
|
244
|
-
const appConfigTemplate = generateAppConfig(vixt);
|
|
245
|
-
const pluginsTemplate = generatePlugins(vixt);
|
|
246
|
-
let code = `// Generated by Vixt
|
|
247
|
-
// This file transform to 'src/main.ts'
|
|
248
|
-
// @ts-nocheck
|
|
249
|
-
${appComponentTemplate}
|
|
250
|
-
${cssTemplate}
|
|
251
|
-
${appConfigTemplate}
|
|
252
|
-
${pluginsTemplate}
|
|
253
|
-
`;
|
|
254
|
-
code = options.transformMain?.(code, vixt) || code;
|
|
255
|
-
fs.outputFileSync(path.resolve(buildDir, "main.ts"), code);
|
|
256
|
-
return code;
|
|
257
|
-
}
|
|
258
|
-
const name$2 = "vixt:app";
|
|
259
|
-
const defaults$1 = {
|
|
260
|
-
rootId: "app",
|
|
261
|
-
rootTag: "div",
|
|
262
|
-
baseURL: "/",
|
|
263
|
-
css: [],
|
|
264
|
-
head: {
|
|
265
|
-
meta: [
|
|
266
|
-
{ charset: "utf-8" },
|
|
267
|
-
{ name: "viewport", content: "width=device-width, initial-scale=1" }
|
|
268
|
-
]
|
|
269
|
-
}
|
|
270
|
-
};
|
|
271
|
-
const app = defineVixtModule({
|
|
272
|
-
meta: { name: name$2, configKey: "app" },
|
|
273
|
-
defaults: defaults$1,
|
|
274
|
-
setup(options, vixt) {
|
|
275
|
-
let indexHtmlCode;
|
|
276
|
-
let mainTsCode;
|
|
277
|
-
const mainTsPath = path.resolve(vixt.options.srcDir, "main.ts");
|
|
278
|
-
return {
|
|
279
|
-
name: name$2,
|
|
280
|
-
configResolved() {
|
|
281
|
-
indexHtmlCode = generateIndexHtml(options, vixt);
|
|
282
|
-
mainTsCode = generateMainTs(options, vixt);
|
|
283
|
-
},
|
|
284
|
-
transformIndexHtml: {
|
|
285
|
-
order: "pre",
|
|
286
|
-
handler() {
|
|
287
|
-
return indexHtmlCode;
|
|
288
|
-
}
|
|
289
|
-
},
|
|
290
|
-
transform: {
|
|
291
|
-
order: "pre",
|
|
292
|
-
handler(_, id) {
|
|
293
|
-
if (id !== mainTsPath)
|
|
294
|
-
return;
|
|
295
|
-
return mainTsCode;
|
|
296
|
-
}
|
|
297
|
-
}
|
|
298
|
-
};
|
|
299
|
-
}
|
|
300
|
-
});
|
|
301
|
-
|
|
302
|
-
function loadEnv(mode, envDir, prefixes) {
|
|
303
|
-
const parsedArgv = cac().parse();
|
|
304
|
-
mode = mode || parsedArgv.options.mode || parsedArgv.options.m || env.NODE_ENV;
|
|
305
|
-
return {
|
|
306
|
-
MODE: mode,
|
|
307
|
-
DEV: env.NODE_ENV !== "production",
|
|
308
|
-
PROD: env.NODE_ENV === "production",
|
|
309
|
-
...loadWorkspaceEnv(mode, prefixes),
|
|
310
|
-
...loadEnv$1(mode, envDir || cwd(), prefixes)
|
|
311
|
-
};
|
|
312
|
-
}
|
|
313
|
-
function loadWorkspaceEnv(mode, prefixes) {
|
|
314
|
-
const workspaceManifestLocation = findUpSync(["pnpm-workspace.yaml", "pnpm-workspace.yml"]);
|
|
315
|
-
return workspaceManifestLocation ? loadEnv$1(mode, path.dirname(workspaceManifestLocation), prefixes) : {};
|
|
316
|
-
}
|
|
317
|
-
|
|
318
144
|
const name$1 = "vixt:config";
|
|
319
145
|
const config = defineVixtModule({
|
|
320
146
|
meta: { name: name$1 },
|
|
@@ -480,7 +306,7 @@ const typescript = defineVixtModule({
|
|
|
480
306
|
async function loadVixt(opts) {
|
|
481
307
|
const result = await loadVixtConfig(defu(opts, {
|
|
482
308
|
defaults: {
|
|
483
|
-
modules: [config,
|
|
309
|
+
modules: [config, typescript]
|
|
484
310
|
}
|
|
485
311
|
}));
|
|
486
312
|
const parsedArgv = cac().parse();
|
|
@@ -505,4 +331,4 @@ function createVixtPlugin(loadOptions) {
|
|
|
505
331
|
});
|
|
506
332
|
}
|
|
507
333
|
|
|
508
|
-
export {
|
|
334
|
+
export { applyLayerModules, applyLayers, config, createVixtPlugin, defineVitePlugin, defineVixtConfig, defineVixtModule, installModule, isSamePath, loadEnv, loadVixt, loadVixtConfig, loadWorkspaceEnv, resolveLayersDirs, typescript };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { PluginOption, ResolvedConfig } from 'vite';
|
|
2
1
|
import { ConfigLayerMeta, ConfigLayer } from 'c12';
|
|
2
|
+
import { PluginOption, ResolvedConfig } from 'vite';
|
|
3
3
|
|
|
4
4
|
interface Vixt {
|
|
5
5
|
options: VixtOptions;
|
|
@@ -78,4 +78,4 @@ interface VixtConfigLayer extends ConfigLayer<VixtOptions, VixtConfigLayerMeta>
|
|
|
78
78
|
interface VixtAppConfig extends Record<string, any> {
|
|
79
79
|
}
|
|
80
80
|
|
|
81
|
-
export type { ModuleOptions as M, PluginOptions as P,
|
|
81
|
+
export type { ModuleOptions as M, PluginOptions as P, VixtOptions as V, VixtConfigLayer as a, VixtConfigLayerMeta as b, ModuleDefinition as c, VixtModule as d, Vixt as e, VixtAppConfig as f, ModuleMeta as g };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { PluginOption, ResolvedConfig } from 'vite';
|
|
2
1
|
import { ConfigLayerMeta, ConfigLayer } from 'c12';
|
|
2
|
+
import { PluginOption, ResolvedConfig } from 'vite';
|
|
3
3
|
|
|
4
4
|
interface Vixt {
|
|
5
5
|
options: VixtOptions;
|
|
@@ -78,4 +78,4 @@ interface VixtConfigLayer extends ConfigLayer<VixtOptions, VixtConfigLayerMeta>
|
|
|
78
78
|
interface VixtAppConfig extends Record<string, any> {
|
|
79
79
|
}
|
|
80
80
|
|
|
81
|
-
export type { ModuleOptions as M, PluginOptions as P,
|
|
81
|
+
export type { ModuleOptions as M, PluginOptions as P, VixtOptions as V, VixtConfigLayer as a, VixtConfigLayerMeta as b, ModuleDefinition as c, VixtModule as d, Vixt as e, VixtAppConfig as f, ModuleMeta as g };
|