@vixt/vue 0.0.1 → 0.0.3
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/index.d.mts +6 -0
- package/dist/index.d.ts +6 -0
- package/dist/index.mjs +128 -0
- package/package.json +2 -8
- package/bin/cli.mjs +0 -40
package/dist/index.d.mts
ADDED
package/dist/index.d.ts
ADDED
package/dist/index.mjs
ADDED
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
import { defineVixtModule, resolveLayersDirs, createVixtPlugin } from '@vixt/core';
|
|
2
|
+
import path from 'pathe';
|
|
3
|
+
import fs from 'fs-extra';
|
|
4
|
+
import defu from 'defu';
|
|
5
|
+
import Vue from '@vitejs/plugin-vue';
|
|
6
|
+
import Layouts from 'vite-plugin-vue-layouts';
|
|
7
|
+
import Components from 'unplugin-vue-components/vite';
|
|
8
|
+
import AutoImport from 'unplugin-auto-import/vite';
|
|
9
|
+
import VueDevTools from 'vite-plugin-vue-devtools';
|
|
10
|
+
import VueRouter from 'unplugin-vue-router/vite';
|
|
11
|
+
import { VueRouterAutoImports } from 'unplugin-vue-router';
|
|
12
|
+
import UnoCSS from 'unocss/vite';
|
|
13
|
+
|
|
14
|
+
function resolveLayersPlugins(layers, from) {
|
|
15
|
+
const { plugins = [] } = resolveLayersDirs(layers);
|
|
16
|
+
return plugins.map((pluginPath) => {
|
|
17
|
+
const pluginsDir = path.relative(from, pluginPath);
|
|
18
|
+
return `${pluginsDir}/*.ts`;
|
|
19
|
+
});
|
|
20
|
+
}
|
|
21
|
+
function generateMainTs(options, vixt, config) {
|
|
22
|
+
const { buildDir } = vixt.options;
|
|
23
|
+
const { rootId } = options;
|
|
24
|
+
const layersPluginsPath = resolveLayersPlugins(vixt._layers, path.join(config.root, buildDir));
|
|
25
|
+
const baseURL = options?.baseURL ?? config.env.BASE_URL ?? "/";
|
|
26
|
+
const cssTemplate = options?.css?.map((e) => `import '${e}'`).join("\n");
|
|
27
|
+
const code = `/** generate by vixt:entry */
|
|
28
|
+
import { createApp } from 'vue'
|
|
29
|
+
import { createRouter, createWebHistory } from 'vue-router'
|
|
30
|
+
import { routes } from 'vue-router/auto-routes'
|
|
31
|
+
import { setupLayouts } from 'virtual:generated-layouts'
|
|
32
|
+
import { createPinia } from 'pinia'
|
|
33
|
+
import { createPersistedState } from 'pinia-plugin-persistedstate'
|
|
34
|
+
import App from '@/App.vue'
|
|
35
|
+
|
|
36
|
+
${cssTemplate}
|
|
37
|
+
|
|
38
|
+
const pinia = createPinia()
|
|
39
|
+
pinia.use(createPersistedState())
|
|
40
|
+
|
|
41
|
+
const router = createRouter({
|
|
42
|
+
routes: setupLayouts(routes),
|
|
43
|
+
history: createWebHistory('${baseURL}'),
|
|
44
|
+
})
|
|
45
|
+
|
|
46
|
+
const app = createApp(App)
|
|
47
|
+
app.use(pinia).use(router)
|
|
48
|
+
// install all plugins under 'plugins/'
|
|
49
|
+
const plugins = import.meta.glob(${JSON.stringify(layersPluginsPath)}, { import: 'default', eager: true })
|
|
50
|
+
// @ts-ignore
|
|
51
|
+
Object.values(plugins).forEach((plugin) => typeof plugin === 'function' && plugin({ app, router, routes, pinia }))
|
|
52
|
+
|
|
53
|
+
app.mount('#${rootId}')
|
|
54
|
+
`;
|
|
55
|
+
fs.outputFileSync(path.resolve(config.root, `${buildDir}/main.ts`), code);
|
|
56
|
+
return code;
|
|
57
|
+
}
|
|
58
|
+
const name = "vixt:entry";
|
|
59
|
+
const defaults$1 = {
|
|
60
|
+
rootId: "app",
|
|
61
|
+
css: ["virtual:uno.css"]
|
|
62
|
+
};
|
|
63
|
+
const entry = defineVixtModule({
|
|
64
|
+
meta: { name, configKey: "app" },
|
|
65
|
+
defaults: defaults$1,
|
|
66
|
+
setup(options, vixt) {
|
|
67
|
+
return {
|
|
68
|
+
name: "vixt:entry",
|
|
69
|
+
configResolved(config) {
|
|
70
|
+
generateMainTs(options, vixt, config);
|
|
71
|
+
}
|
|
72
|
+
};
|
|
73
|
+
}
|
|
74
|
+
});
|
|
75
|
+
|
|
76
|
+
const presetVue = defineVixtModule({
|
|
77
|
+
async setup(_, vixt) {
|
|
78
|
+
const { components, composables = [], constants = [], utils = [], stores = [], pages, layouts } = resolveLayersDirs(vixt._layers);
|
|
79
|
+
const { buildTypesDir } = vixt.options;
|
|
80
|
+
const defaultOptions = {
|
|
81
|
+
vue: {},
|
|
82
|
+
router: { dts: `${buildTypesDir}/typed-router.d.ts`, routesFolder: pages },
|
|
83
|
+
layouts: { layoutsDirs: layouts, pagesDirs: pages },
|
|
84
|
+
components: {
|
|
85
|
+
dts: `${buildTypesDir}/components.d.ts`,
|
|
86
|
+
dirs: components,
|
|
87
|
+
directoryAsNamespace: true,
|
|
88
|
+
collapseSamePrefixes: true,
|
|
89
|
+
allowOverrides: true
|
|
90
|
+
},
|
|
91
|
+
imports: {
|
|
92
|
+
imports: ["vue", "@vueuse/core", "pinia", VueRouterAutoImports],
|
|
93
|
+
dts: `${buildTypesDir}/auto-imports.d.ts`,
|
|
94
|
+
dirs: [...composables, ...constants, ...stores, ...utils],
|
|
95
|
+
vueTemplate: true
|
|
96
|
+
},
|
|
97
|
+
unocss: {},
|
|
98
|
+
devtools: {}
|
|
99
|
+
};
|
|
100
|
+
const options = defu(vixt.options, defaultOptions);
|
|
101
|
+
const plugins = [
|
|
102
|
+
VueRouter(options.router),
|
|
103
|
+
Vue(options.vue),
|
|
104
|
+
Layouts(options.layouts),
|
|
105
|
+
Components(options.components),
|
|
106
|
+
AutoImport(options.imports),
|
|
107
|
+
UnoCSS(options.unocss),
|
|
108
|
+
VueDevTools(options.devtools)
|
|
109
|
+
];
|
|
110
|
+
return plugins;
|
|
111
|
+
}
|
|
112
|
+
});
|
|
113
|
+
|
|
114
|
+
const defaults = {
|
|
115
|
+
modules: [entry, presetVue],
|
|
116
|
+
app: {
|
|
117
|
+
head: {
|
|
118
|
+
link: [{ rel: "icon", href: "/favicon.ico" }]
|
|
119
|
+
}
|
|
120
|
+
},
|
|
121
|
+
typescript: {
|
|
122
|
+
references: ["types/typed-router.d.ts", "types/components.d.ts", "types/auto-imports.d.ts", "types/vite-env.d.ts"],
|
|
123
|
+
tsConfig: { compilerOptions: { types: ["vite-plugin-vue-layouts/client", "unplugin-vue-router/client"] } }
|
|
124
|
+
}
|
|
125
|
+
};
|
|
126
|
+
const index = createVixtPlugin({ defaults });
|
|
127
|
+
|
|
128
|
+
export { index as default };
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vixt/vue",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.0.
|
|
4
|
+
"version": "0.0.3",
|
|
5
5
|
"author": "SoulLyoko<https://github.com/SoulLyoko>",
|
|
6
6
|
"license": "MIT",
|
|
7
7
|
"homepage": "https://github.com/SoulLyoko/vixt#readme",
|
|
@@ -10,16 +10,10 @@
|
|
|
10
10
|
".": {
|
|
11
11
|
"types": "./dist/index.d.ts",
|
|
12
12
|
"import": "./dist/index.mjs"
|
|
13
|
-
},
|
|
14
|
-
"./cli": {
|
|
15
|
-
"import": "./bin/cli.mjs"
|
|
16
13
|
}
|
|
17
14
|
},
|
|
18
15
|
"main": "dist/index.mjs",
|
|
19
16
|
"types": "dist/index.d.ts",
|
|
20
|
-
"bin": {
|
|
21
|
-
"vixt": "bin/cli.mjs"
|
|
22
|
-
},
|
|
23
17
|
"files": [
|
|
24
18
|
"dist"
|
|
25
19
|
],
|
|
@@ -37,7 +31,7 @@
|
|
|
37
31
|
"vite-plugin-vue-layouts": "^0.11.0",
|
|
38
32
|
"vue": "^3.4.31",
|
|
39
33
|
"vue-router": "^4.4.0",
|
|
40
|
-
"@vixt/core": "0.0.
|
|
34
|
+
"@vixt/core": "0.0.3"
|
|
41
35
|
},
|
|
42
36
|
"scripts": {
|
|
43
37
|
"build": "unbuild"
|
package/bin/cli.mjs
DELETED
|
@@ -1,40 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env
|
|
2
|
-
import { argv } from 'node:process'
|
|
3
|
-
import { execSync } from 'node:child_process'
|
|
4
|
-
|
|
5
|
-
import { resolvePathSync } from 'mlly'
|
|
6
|
-
import path from 'pathe'
|
|
7
|
-
// import { createServer, build as viteBuild, preview as vitePreview } from 'vite'
|
|
8
|
-
|
|
9
|
-
const vite = path.resolve(resolvePathSync('vite'), '../../../bin/vite.js')
|
|
10
|
-
|
|
11
|
-
const args = argv.slice(2).join(' ')
|
|
12
|
-
|
|
13
|
-
execSync(`node --import=tsx ${vite} ${args} `, { stdio: 'inherit' })
|
|
14
|
-
|
|
15
|
-
// async function start() {
|
|
16
|
-
// const server = await createServer({
|
|
17
|
-
// configFile: './vite.config.ts',
|
|
18
|
-
// })
|
|
19
|
-
|
|
20
|
-
// await server.listen()
|
|
21
|
-
|
|
22
|
-
// server.printUrls()
|
|
23
|
-
// }
|
|
24
|
-
|
|
25
|
-
// async function build() {
|
|
26
|
-
// await viteBuild({
|
|
27
|
-
// configFile: './vite.config.ts',
|
|
28
|
-
// })
|
|
29
|
-
// }
|
|
30
|
-
|
|
31
|
-
// async function preview() {
|
|
32
|
-
// const server = await vitePreview({
|
|
33
|
-
// configFile: './vite.config.ts',
|
|
34
|
-
// })
|
|
35
|
-
|
|
36
|
-
// server.printUrls()
|
|
37
|
-
// server.bindCLIShortcuts({ print: true })
|
|
38
|
-
// }
|
|
39
|
-
|
|
40
|
-
// await start()
|