diff --git a/bun.lockb b/bun.lockb index ae45d1f..0e29926 100644 Binary files a/bun.lockb and b/bun.lockb differ diff --git a/demo/public/favicon.ico b/demo/public/favicon.ico new file mode 100644 index 0000000..c48857c Binary files /dev/null and b/demo/public/favicon.ico differ diff --git a/package.json b/package.json index 6070838..cdec864 100644 --- a/package.json +++ b/package.json @@ -39,7 +39,7 @@ "vue": "3.4.21", "vue-loader": "17.4.2", "vue-router": "4.4.0", - "vulxi": "0.0.10", + "vulxi": "0.0.11", "yargs": "17.7.1", "yarpm": "1.2.0" } diff --git a/src/config/aliases.js b/src/config/aliases.js index 9d5f0fe..2ac6d6e 100644 --- a/src/config/aliases.js +++ b/src/config/aliases.js @@ -11,8 +11,9 @@ const VulmixAliases = () => { '@@': `${ABSOLUTE_PACKAGE_PATH}/src`, '@appFile': fs.existsSync(`${ABSOLUTE_ROOT_PATH}/app.vue`) ? `${ABSOLUTE_ROOT_PATH}/app.vue` - : fs.existsSync(`${ABSOLUTE_ROOT_PATH}/pages/index.vue`) - ? `${ABSOLUTE_ROOT_PATH}/pages/index.vue` + : fs.existsSync(`${ABSOLUTE_ROOT_PATH}/pages/index.vue`) && + !fs.existsSync(`${ABSOLUTE_ROOT_PATH}/app.vue`) + ? `${ABSOLUTE_PACKAGE_PATH}/src/vue/pages/app.vue` : `${ABSOLUTE_PACKAGE_PATH}/src/vue/pages/404.vue`, '@assets': fs.existsSync(`${ABSOLUTE_ROOT_PATH}/assets`) ? `${ABSOLUTE_ROOT_PATH}/assets` diff --git a/src/index.ejs b/src/index.ejs index 91bd132..7ea1910 100644 --- a/src/index.ejs +++ b/src/index.ejs @@ -23,8 +23,8 @@
- - - + + + diff --git a/src/mix.js b/src/mix.js index 1c01cf0..1af04a4 100644 --- a/src/mix.js +++ b/src/mix.js @@ -41,6 +41,9 @@ class VulmixInit { const VULMIX_CONFIG_PATH = `${ABSOLUTE_ROOT_PATH}/.vulmix/vulmix.config.js` const VulmixConfig = require(VULMIX_CONFIG_PATH).default + const APP_PUBLIC_PATH = VulmixConfig.dirs?.public + ? `${ABSOLUTE_ROOT_PATH}/${VulmixConfig.dirs?.public?.replace('/', '')}/` + : `${ABSOLUTE_ROOT_PATH}/public/` useConsole.clear() useConsole.log( @@ -188,21 +191,12 @@ class VulmixInit { force: true, }) - if (!fs.existsSync(`${ABSOLUTE_ROOT_PATH}/_dist/assets/img`)) { - fs.mkdirSync(`${ABSOLUTE_ROOT_PATH}/_dist/assets/img`, { - recursive: true, - }) + if (fs.existsSync(APP_PUBLIC_PATH)) { + mix.copy(APP_PUBLIC_PATH, `${ABSOLUTE_ROOT_PATH}/_dist/`) } } catch (error) { console.log(`\n${chalk.red(error)}`) } finally { - if (fs.existsSync(`${ABSOLUTE_ROOT_PATH}/assets/`)) { - mix.copy( - `${ABSOLUTE_ROOT_PATH}/assets`, - `${ABSOLUTE_ROOT_PATH}/_dist/assets` - ) - } - mix .setPublicPath(RELATIVE_PUBLIC_PATH) @@ -230,7 +224,7 @@ class VulmixInit { .ts( `${ABSOLUTE_PACKAGE_PATH}/src/vue/main.ts`, - `${ABSOLUTE_ROOT_PATH}/_dist/assets/_vulmix/js/main.vulmix.js` + `${ABSOLUTE_ROOT_PATH}/_dist/_vulmix/js/main.vulmix.js` ) .after(stats => { @@ -287,25 +281,11 @@ class VulmixInit { }) try { - fs.rmSync(`${ABSOLUTE_ROOT_PATH}/.vulmix/client/assets`, { - recursive: true, - force: true, - }) - - if (!fs.existsSync(`${ABSOLUTE_ROOT_PATH}/.vulmix/client/assets`)) { - fs.mkdirSync(`${ABSOLUTE_ROOT_PATH}/.vulmix/client/assets`, { - recursive: true, - }) + if (fs.existsSync(APP_PUBLIC_PATH)) { + mix.copy(APP_PUBLIC_PATH, `${ABSOLUTE_ROOT_PATH}/.vulmix/client`) } } catch (error) { console.log(`\n${chalk.red(error)}`) - } finally { - if (fs.existsSync(`${ABSOLUTE_ROOT_PATH}/assets/`)) { - mix.copy( - `${ABSOLUTE_ROOT_PATH}/assets`, - `${ABSOLUTE_ROOT_PATH}/.vulmix/client/assets` - ) - } } mix @@ -341,7 +321,7 @@ class VulmixInit { .ts( `${ABSOLUTE_PACKAGE_PATH}/src/vue/main.ts`, - `${ABSOLUTE_ROOT_PATH}/.vulmix/client/assets/_vulmix/js/main.vulmix.js` + `${ABSOLUTE_ROOT_PATH}/.vulmix/client/_vulmix/js/main.vulmix.js` ) .sourceMaps() diff --git a/src/vue/components/App.vue b/src/vue/components/Page.vue similarity index 65% rename from src/vue/components/App.vue rename to src/vue/components/Page.vue index 7317fce..9e5a468 100644 --- a/src/vue/components/App.vue +++ b/src/vue/components/Page.vue @@ -5,11 +5,11 @@ diff --git a/src/vue/components/VulmixWelcome.vue b/src/vue/components/VulmixWelcome.vue index 6989ad2..d41bf5e 100644 --- a/src/vue/components/VulmixWelcome.vue +++ b/src/vue/components/VulmixWelcome.vue @@ -113,7 +113,7 @@

If you want to enable file based routing, inside app.vue, replace <VulmixWelcome /> with - <App /> and create your routes inside a + <Page /> and create your routes inside a /pages directory.

diff --git a/src/vue/main.ts b/src/vue/main.ts index ad26cd0..5cb287d 100644 --- a/src/vue/main.ts +++ b/src/vue/main.ts @@ -1,6 +1,6 @@ -import { createApp, App as VueApp } from 'vue' -import { createRouter, createWebHistory, Router } from 'vue-router' -import { createHead, VueHeadClient } from '@unhead/vue' +import { createApp, type App as VueApp } from 'vue' +import { createRouter, createWebHistory, type Router } from 'vue-router' +import { createHead, type VueHeadClient } from '@unhead/vue' import { createPinia } from 'pinia' const App = require('@appFile').default diff --git a/src/vue/pages/app.vue b/src/vue/pages/app.vue new file mode 100644 index 0000000..c65449b --- /dev/null +++ b/src/vue/pages/app.vue @@ -0,0 +1,3 @@ + diff --git a/types/head/link.ts b/types/head/link.ts new file mode 100644 index 0000000..bda630f --- /dev/null +++ b/types/head/link.ts @@ -0,0 +1,46 @@ +export type LinkRel = + | 'stylesheet' + | 'icon' + | 'apple-touch-icon' + | 'mask-icon' + | 'canonical' + | 'manifest' + | 'author' + | 'licence' + | 'alternate' + | 'me' + | 'dns-prefetch' + | 'preconnect' + | 'prefetch' + | 'prerender' + | 'preload' + | 'modulepreload' + +export type LinkType = + | 'text/css' + | 'text/plain' + | 'text/html' + | 'text/javascript' + | 'application/javascript' + | 'application/json' + | 'application/manifest+json' + | 'application/rss+xml' + | 'application/atom+xml' + | 'application/pdf' + | 'application/zip' + | 'application/x-font-ttf' + | 'application/x-font-opentype' + | 'application/x-font-woff' + | 'application/x-font-woff2' + | 'application/x-font-eot' + | 'application/x-font-truetype' + | 'image/svg+xml' + | 'image/x-icon' + | 'image/png' + | 'image/jpeg' + | 'image/gif' + | 'image/webp' + | 'image/avif' + | 'image/apng' + | 'image/bmp' + | 'image/vnd.microsoft.icon' diff --git a/types/head/meta.ts b/types/head/meta.ts new file mode 100644 index 0000000..511a6a7 --- /dev/null +++ b/types/head/meta.ts @@ -0,0 +1,78 @@ +export type MetaCharset = 'utf-8' | 'iso-8859-1' | 'iso-8859-2' | 'utf-16' + +export type MetaName = + | 'viewport' + | 'description' + | 'keywords' + | 'author' + | 'generator' + | 'robots' + | 'googlebot' + | 'google' + | 'bingbot' + | 'bing' + | 'yandexbot' + | 'yandex' + | 'yandex-verification' + | 'apple-mobile-web-app-title' + | 'application-name' + | 'msapplication-TileColor' + | 'theme-color' + | 'msapplication-TileImage' + | 'msapplication-config' + | 'mobile-web-app-capable' + | 'apple-mobile-web-app-capable' + | 'apple-mobile-web-app-status-bar-style' + | 'format-detection' + | 'apple-touch-fullscreen' + | 'og:title' + | 'og:description' + | 'og:image' + | 'og:url' + | 'og:site_name' + | 'og:locale' + | 'og:type' + | 'og:audio' + | 'og:video' + | 'og:determiner' + | 'og:updated_time' + | 'og:locale:alternate' + | 'twitter:card' + | 'twitter:site' + | 'twitter:site:id' + | 'twitter:creator' + | 'twitter:creator:id' + | 'twitter:title' + | 'twitter:description' + | 'twitter:image' + | 'twitter:image:alt' + | 'twitter:player' + | 'twitter:player:width' + | 'twitter:player:height' + | 'twitter:player:stream' + | 'twitter:player:stream:content_type' + | 'twitter:app:name:iphone' + | 'twitter:app:id:iphone' + | 'twitter:app:url:iphone' + | 'twitter:app:name:ipad' + | 'twitter:app:id:ipad' + | 'twitter:app:url:ipad' + | 'twitter:app:name:googleplay' + | 'twitter:app:id:googleplay' + | 'twitter:app:url:googleplay' + | 'twitter:label1' + | 'twitter:data1' + | 'twitter:label2' + | 'twitter:data2' + | 'fb:app_id' + | 'fb:pages' + | 'fb:admins' + | 'fb:profile_id' + | 'fb:article_style' + | 'fb:use_automatic_ad_placement' + | 'fb:enable_native_login' + +export type MetaProperty = + | 'X-UA-Compatible' + | 'Content-Type' + | 'Content-Language' diff --git a/types/vulmix-config.d.ts b/types/vulmix-config.d.ts index ee8d5cd..37938c8 100644 --- a/types/vulmix-config.d.ts +++ b/types/vulmix-config.d.ts @@ -1,3 +1,6 @@ +import type { MetaCharset, MetaName, MetaProperty } from './head/meta' +import type { LinkRel, LinkType } from './head/link' + export interface VulmixConfig { lang?: string @@ -6,138 +9,29 @@ export interface VulmixConfig { presets?: string[] } + dirs?: { + public?: string + }, + head?: { title?: string meta?: { - charset?: 'utf-8' | 'iso-8859-1' | 'iso-8859-2' | 'utf-16' - name?: - | 'viewport' - | 'description' - | 'keywords' - | 'author' - | 'generator' - | 'robots' - | 'googlebot' - | 'google' - | 'bingbot' - | 'bing' - | 'yandexbot' - | 'yandex' - | 'yandex-verification' - | 'apple-mobile-web-app-title' - | 'application-name' - | 'msapplication-TileColor' - | 'theme-color' - | 'msapplication-TileImage' - | 'msapplication-config' - | 'mobile-web-app-capable' - | 'apple-mobile-web-app-capable' - | 'apple-mobile-web-app-status-bar-style' - | 'format-detection' - | 'apple-touch-fullscreen' - | 'og:title' - | 'og:description' - | 'og:image' - | 'og:url' - | 'og:site_name' - | 'og:locale' - | 'og:type' - | 'og:audio' - | 'og:video' - | 'og:determiner' - | 'og:updated_time' - | 'og:locale:alternate' - | 'twitter:card' - | 'twitter:site' - | 'twitter:site:id' - | 'twitter:creator' - | 'twitter:creator:id' - | 'twitter:title' - | 'twitter:description' - | 'twitter:image' - | 'twitter:image:alt' - | 'twitter:player' - | 'twitter:player:width' - | 'twitter:player:height' - | 'twitter:player:stream' - | 'twitter:player:stream:content_type' - | 'twitter:app:name:iphone' - | 'twitter:app:id:iphone' - | 'twitter:app:url:iphone' - | 'twitter:app:name:ipad' - | 'twitter:app:id:ipad' - | 'twitter:app:url:ipad' - | 'twitter:app:name:googleplay' - | 'twitter:app:id:googleplay' - | 'twitter:app:url:googleplay' - | 'twitter:label1' - | 'twitter:data1' - | 'twitter:label2' - | 'twitter:data2' - | 'fb:app_id' - | 'fb:pages' - | 'fb:admins' - | 'fb:profile_id' - | 'fb:article_style' - | 'fb:use_automatic_ad_placement' - | 'fb:enable_native_login' + charset?: MetaCharset + name?: MetaName property?: string - 'http-equiv'?: 'X-UA-Compatible' | 'Content-Type' | 'Content-Language' + 'http-equiv'?: MetaProperty content?: string }[] link?: { - rel?: - | 'stylesheet' - | 'icon' - | 'apple-touch-icon' - | 'mask-icon' - | 'canonical' - | 'manifest' - | 'author' - | 'licence' - | 'alternate' - | 'me' - | 'dns-prefetch' - | 'preconnect' - | 'prefetch' - | 'prerender' - | 'preload' - | 'modulepreload' + rel?: LinkRel sizes?: string href?: string hreflang?: string - type?: - | 'text/css' - | 'text/plain' - | 'text/html' - | 'text/javascript' - | 'application/javascript' - | 'application/json' - | 'application/manifest+json' - | 'application/rss+xml' - | 'application/atom+xml' - | 'application/pdf' - | 'application/zip' - | 'application/x-font-ttf' - | 'application/x-font-opentype' - | 'application/x-font-woff' - | 'application/x-font-woff2' - | 'application/x-font-eot' - | 'application/x-font-truetype' - | 'image/svg+xml' - | 'image/x-icon' - | 'image/png' - | 'image/jpeg' - | 'image/gif' - | 'image/webp' - | 'image/avif' - | 'image/apng' - | 'image/bmp' - | 'image/vnd.microsoft.icon' + type?: LinkType }[] script?: {