Skip to content

Commit

Permalink
cf-pages
Browse files Browse the repository at this point in the history
  • Loading branch information
webees committed Sep 16, 2023
1 parent 83b1170 commit 6772aed
Show file tree
Hide file tree
Showing 9 changed files with 21 additions and 7 deletions.
1 change: 0 additions & 1 deletion .env

This file was deleted.

2 changes: 2 additions & 0 deletions .env.development
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
BASE_URL='/'
VUE_APP_PUBLIC_PATH='/'
2 changes: 2 additions & 0 deletions .env.production
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
BASE_URL='/'
VUE_APP_PUBLIC_PATH='//fastly.jsdelivr.net/gh/webees/tfjs-yolov8@cf-pages/'
2 changes: 1 addition & 1 deletion .github/workflows/pages.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -32,5 +32,5 @@ jobs:
- name: Deploy 🚀
uses: JamesIves/github-pages-deploy-action@v4
with:
BRANCH: gh-pages
BRANCH: cf-pages
FOLDER: dist
3 changes: 3 additions & 0 deletions public/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,11 @@
<script src="//fastly.jsdelivr.net/npm/[email protected]/dist/vue.global<%= IS_DEV ? '.' : '.prod.' %>js"></script>
<script src="//fastly.jsdelivr.net/npm/[email protected]/dist/vue-router.global<%= IS_DEV ? '.' : '.prod.' %>js"></script>
<script src="//fastly.jsdelivr.net/npm/[email protected]/dist/vue-i18n.global<%= IS_DEV ? '.' : '.prod.' %>js"></script>
<script src="//fastly.jsdelivr.net/npm/[email protected]/dist/pinia.iife.prod.js"></script>
<script src="//fastly.jsdelivr.net/npm/[email protected]/dist/axios.min.js"></script>
<script src="//fastly.jsdelivr.net/npm/[email protected]/lib/vant.min.js"></script>
<script src="//fastly.jsdelivr.net/npm/@tensorflow/[email protected]/dist/tf.min.js"></script>
<script src="//fastly.jsdelivr.net/npm/@tensorflow/[email protected]/dist/tf-backend-webgl.min.js"></script>
</head>
<body>
<noscript>
Expand Down
2 changes: 1 addition & 1 deletion src/registerServiceWorker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import { register } from 'register-service-worker'

if (process.env.NODE_ENV === 'production') {
register(`${process.env.BASE_URL}service-worker.js`, {
register(`/service-worker.js`, {
ready() {
console.log('App is being served from cache by a service worker.\n' + 'For more details, visit https://goo.gl/AFskqB')
},
Expand Down
2 changes: 1 addition & 1 deletion src/utils/tf.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { yolo } from '@/vue-pinia'

export function loadModel() {
tf.ready().then(async () => {
const model = await tf.loadGraphModel(`/${yolo().name}_web_model/model.json`, {
const model = await tf.loadGraphModel(`${process.env.VUE_APP_PUBLIC_PATH}${yolo().name}_web_model/model.json`, {
onProgress: progress => {
console.log('tf.loadGraphModel', progress)
yolo().loading = progress
Expand Down
2 changes: 1 addition & 1 deletion src/vue-router.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ const routes: Array<RouteRecordRaw> = [
]

const router = createRouter({
history: createWebHistory(process.env.BASE_URL),
history: createWebHistory('/'),
routes,
linkActiveClass: 'active',
scrollBehavior(to, from, savedPosition) {
Expand Down
12 changes: 10 additions & 2 deletions vue.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ const vueServe = c => {
}

const vueConfig = {
publicPath: IS_DEV ? '/' : '//fastly.jsdelivr.net/gh/webees/tfjs-yolov8@gh-pages/',
publicPath: process.env.VUE_APP_PUBLIC_PATH,
outputDir: 'dist',
productionSourceMap: IS_DEV,
integrity: false,
Expand All @@ -50,13 +50,21 @@ const vueConfig = {
open: false,
proxy: null
},
pwa: {
manifestOptions: {
start_url: '/'
}
},
configureWebpack: {
externals: {
'vue-router': 'VueRouter',
'vue-i18n': 'VueI18n',
vue: 'Vue',
axios: 'axios',
vant: 'vant'
vant: 'vant',
pinia: 'Pinia',
'@tensorflow/tfjs': 'tf',
'@tensorflow/tfjs-backend-webgl': 'tf.backend'
},
plugins: [
require('unplugin-vue-components/webpack')({
Expand Down

0 comments on commit 6772aed

Please sign in to comment.