Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: configurable /public folder #255

Merged
merged 10 commits into from
Jul 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file modified bun.lockb
Binary file not shown.
Binary file added demo/public/favicon.ico
Binary file not shown.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}
Expand Down
5 changes: 3 additions & 2 deletions src/config/aliases.js
Original file line number Diff line number Diff line change
Expand Up @@ -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`
Expand Down
6 changes: 3 additions & 3 deletions src/index.ejs
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@
<body>
<div data-vulmix-app></div>

<script src="<%= mix('/assets/_vulmix/js/manifest.js') %>"></script>
<script src="<%= mix('/assets/_vulmix/js/vendor.js') %>"></script>
<script src="<%= mix('/assets/_vulmix/js/main.vulmix.js') %>"></script>
<script src="<%= mix('/_vulmix/js/manifest.js') %>"></script>
<script src="<%= mix('/_vulmix/js/vendor.js') %>"></script>
<script src="<%= mix('/_vulmix/js/main.vulmix.js') %>"></script>
</body>
</html>
38 changes: 9 additions & 29 deletions src/mix.js
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down Expand Up @@ -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)

Expand Down Expand Up @@ -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 => {
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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()
Expand Down
8 changes: 4 additions & 4 deletions src/vue/components/App.vue → src/vue/components/Page.vue
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@
<template>
<Suspense>
<RouterView v-slot="{ Component, route }">
<Transition :name="(route?.meta?.transition as string)" mode="out-in">
<Suspense>
<Suspense>
<Transition :name="(route?.meta?.transition as string)" mode="out-in">
<Component :is="Component" :key="route.fullPath" />
</Suspense>
</Transition>
</Transition>
</Suspense>
</RouterView>
</Suspense>
</template>
2 changes: 1 addition & 1 deletion src/vue/components/VulmixWelcome.vue
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@
<p>
If you want to enable file based routing, inside <code>app.vue</code>,
replace <code>&lt;VulmixWelcome /&gt;</code> with
<code>&lt;App /&gt;</code> and create your routes inside a
<code>&lt;Page /&gt;</code> and create your routes inside a
<code>/pages</code> directory.
</p>

Expand Down
6 changes: 3 additions & 3 deletions src/vue/main.ts
Original file line number Diff line number Diff line change
@@ -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
Expand Down
3 changes: 3 additions & 0 deletions src/vue/pages/app.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<template>
<Page />
</template>
46 changes: 46 additions & 0 deletions types/head/link.ts
Original file line number Diff line number Diff line change
@@ -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'
78 changes: 78 additions & 0 deletions types/head/meta.ts
Original file line number Diff line number Diff line change
@@ -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'
Loading