@vixt/vue 0.0.15 → 0.1.1

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 CHANGED
@@ -1,6 +1,6 @@
1
1
  import * as vite from 'vite';
2
2
  import * as _vixt_core from '@vixt/core';
3
- import { AppOptions, PluginOptions, VixtOptions } from '@vixt/core';
3
+ import { PluginOptions, VixtOptions } from '@vixt/core';
4
4
  import Vue from '@vitejs/plugin-vue';
5
5
  import Layouts from 'vite-plugin-vue-layouts';
6
6
  import Components from 'unplugin-vue-components/vite';
@@ -9,8 +9,6 @@ import VueDevTools from 'vite-plugin-vue-devtools';
9
9
  import VueRouter from 'unplugin-vue-router/vite';
10
10
  import UnoCSS from 'unocss/vite';
11
11
 
12
- declare const entryVue: _vixt_core.VixtModule<AppOptions>;
13
-
14
12
  declare module '@vixt/core' {
15
13
  interface VixtOptions {
16
14
  vue?: PluginOptions<typeof Vue>;
@@ -34,4 +32,4 @@ declare const presetVue: _vixt_core.VixtModule<VixtOptions>;
34
32
 
35
33
  declare const _default: (options?: VixtOptions | undefined) => vite.PluginOption;
36
34
 
37
- export { _default as default, entryVue, presetVue };
35
+ export { _default as default, presetVue };
package/dist/index.d.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  import * as vite from 'vite';
2
2
  import * as _vixt_core from '@vixt/core';
3
- import { AppOptions, PluginOptions, VixtOptions } from '@vixt/core';
3
+ import { PluginOptions, VixtOptions } from '@vixt/core';
4
4
  import Vue from '@vitejs/plugin-vue';
5
5
  import Layouts from 'vite-plugin-vue-layouts';
6
6
  import Components from 'unplugin-vue-components/vite';
@@ -9,8 +9,6 @@ import VueDevTools from 'vite-plugin-vue-devtools';
9
9
  import VueRouter from 'unplugin-vue-router/vite';
10
10
  import UnoCSS from 'unocss/vite';
11
11
 
12
- declare const entryVue: _vixt_core.VixtModule<AppOptions>;
13
-
14
12
  declare module '@vixt/core' {
15
13
  interface VixtOptions {
16
14
  vue?: PluginOptions<typeof Vue>;
@@ -34,4 +32,4 @@ declare const presetVue: _vixt_core.VixtModule<VixtOptions>;
34
32
 
35
33
  declare const _default: (options?: VixtOptions | undefined) => vite.PluginOption;
36
34
 
37
- export { _default as default, entryVue, presetVue };
35
+ export { _default as default, presetVue };
package/dist/index.mjs CHANGED
@@ -1,6 +1,4 @@
1
1
  import { defineVixtModule, resolveLayersDirs, createVixtPlugin } from '@vixt/core';
2
- import path from 'pathe';
3
- import fs from 'fs-extra';
4
2
  import defu from 'defu';
5
3
  import Vue from '@vitejs/plugin-vue';
6
4
  import Layouts from 'vite-plugin-vue-layouts';
@@ -11,70 +9,6 @@ import VueRouter from 'unplugin-vue-router/vite';
11
9
  import { VueRouterAutoImports } from 'unplugin-vue-router';
12
10
  import UnoCSS from 'unocss/vite';
13
11
 
14
- function resolveLayersPlugins(layers, from) {
15
- const { plugins = [] } = resolveLayersDirs(layers);
16
- return plugins.map((pluginPath) => {
17
- let pluginsDir = path.relative(from, pluginPath);
18
- if (!pluginPath.startsWith(".") && !pluginPath.startsWith("/")) {
19
- pluginsDir = `./${pluginsDir}`;
20
- }
21
- return `${pluginsDir}/*.ts`;
22
- });
23
- }
24
- function generateMainTs(options, vixt) {
25
- const { buildDir, rootDir } = vixt.options;
26
- const { rootId, baseURL } = options;
27
- const layersPluginsPath = resolveLayersPlugins(vixt._layers, path.join(rootDir, buildDir));
28
- const cssTemplate = options?.css?.map((e) => `import '${e}'`).join("\n");
29
- const code = `/** Generated by Vixt */
30
- // @ts-nocheck
31
- import { createApp } from 'vue'
32
- import { createRouter, createWebHistory } from 'vue-router'
33
- import { routes } from 'vue-router/auto-routes'
34
- import { setupLayouts } from 'virtual:generated-layouts'
35
- import { createPinia } from 'pinia'
36
- import { createPersistedState } from 'pinia-plugin-persistedstate'
37
-
38
- import App from '@/App.vue'
39
- ${cssTemplate}
40
-
41
- const pinia = createPinia()
42
- pinia.use(createPersistedState())
43
-
44
- const router = createRouter({
45
- routes: setupLayouts(routes),
46
- history: createWebHistory('${baseURL}'),
47
- })
48
-
49
- const app = createApp(App)
50
- app.use(pinia).use(router)
51
- // install all plugins under 'plugins/'
52
- const plugins = import.meta.glob(${JSON.stringify(layersPluginsPath)}, { import: 'default', eager: true })
53
- // @ts-ignore
54
- Object.values(plugins).forEach((plugin) => typeof plugin === 'function' && plugin({ app, router, routes, pinia }))
55
-
56
- app.mount('#${rootId}')
57
- `;
58
- fs.outputFileSync(path.resolve(rootDir, buildDir, "main.ts"), code);
59
- return code;
60
- }
61
- const name = "vixt:entry-vue";
62
- const defaults$1 = {
63
- baseURL: "/",
64
- rootId: "app",
65
- css: ["virtual:uno.css"]
66
- };
67
- const entryVue = defineVixtModule({
68
- meta: { name, configKey: "app" },
69
- defaults: defaults$1,
70
- setup(options, vixt) {
71
- generateMainTs(options, vixt);
72
- return {
73
- name
74
- };
75
- }
76
- });
77
-
78
12
  const presetVue = defineVixtModule({
79
13
  async setup(_, vixt) {
80
14
  const { components, composables = [], constants = [], utils = [], stores = [], pages, layouts } = resolveLayersDirs(vixt._layers);
@@ -113,10 +47,40 @@ const presetVue = defineVixtModule({
113
47
  });
114
48
 
115
49
  const defaults = {
116
- modules: [entryVue, presetVue],
50
+ modules: [presetVue],
117
51
  app: {
118
52
  head: {
119
53
  link: [{ rel: "icon", href: "/favicon.ico" }]
54
+ },
55
+ baseURL: "/",
56
+ rootId: "app",
57
+ css: ["virtual:uno.css"],
58
+ transformMain(code, vixt) {
59
+ const { app } = vixt.options;
60
+ code += `
61
+ import { createApp } from 'vue'
62
+ import { createPinia } from 'pinia'
63
+ import { createPersistedState } from 'pinia-plugin-persistedstate'
64
+ import { createRouter, createWebHistory } from 'vue-router'
65
+ import { routes } from 'vue-router/auto-routes'
66
+ import { setupLayouts } from 'virtual:generated-layouts'
67
+
68
+ const pinia = createPinia()
69
+ pinia.use(createPersistedState())
70
+
71
+ const router = createRouter({
72
+ routes: setupLayouts(routes),
73
+ history: createWebHistory('${app.baseURL}'),
74
+ })
75
+
76
+ const app = createApp(App)
77
+ app.use(pinia).use(router)
78
+
79
+ Object.values(plugins).forEach((plugin) => typeof plugin === 'function' && plugin({ app, router, routes, pinia, appConfig }))
80
+
81
+ app.mount('#${app.rootId}')
82
+ `;
83
+ return code;
120
84
  }
121
85
  },
122
86
  typescript: {
@@ -127,4 +91,4 @@ const defaults = {
127
91
  };
128
92
  const index = createVixtPlugin({ defaults });
129
93
 
130
- export { index as default, entryVue, presetVue };
94
+ export { index as default, presetVue };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@vixt/vue",
3
3
  "type": "module",
4
- "version": "0.0.15",
4
+ "version": "0.1.1",
5
5
  "author": "SoulLyoko<https://github.com/SoulLyoko>",
6
6
  "license": "MIT",
7
7
  "homepage": "https://github.com/SoulLyoko/vixt#readme",
@@ -24,14 +24,14 @@
24
24
  "pinia": "^2.1.7",
25
25
  "pinia-plugin-persistedstate": "^3.2.1",
26
26
  "unocss": "^0.61.3",
27
- "unplugin-auto-import": "^0.17.6",
27
+ "unplugin-auto-import": "^0.18.0",
28
28
  "unplugin-vue-components": "^0.27.2",
29
29
  "unplugin-vue-router": "^0.10.0",
30
30
  "vite-plugin-vue-devtools": "^7.3.5",
31
31
  "vite-plugin-vue-layouts": "^0.11.0",
32
32
  "vue": "^3.4.31",
33
33
  "vue-router": "^4.4.0",
34
- "@vixt/core": "0.0.15"
34
+ "@vixt/core": "0.1.1"
35
35
  },
36
36
  "scripts": {
37
37
  "build": "unbuild"