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 5c91f20
Show file tree
Hide file tree
Showing 11 changed files with 34 additions and 14 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
16 changes: 10 additions & 6 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@
"serve": "vue-cli-service serve",
"build": "vue-cli-service build",
"lint": "vue-cli-service lint",
"taze": "npx taze"
"taze": "npx taze",
"ubd": "npx update-browserslist-db@latest"
},
"dependencies": {
"@tensorflow/tfjs": "^4.11.0",
Expand Down
2 changes: 2 additions & 0 deletions public/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@
<script src="//fastly.jsdelivr.net/npm/vue-i18n@9.4/dist/vue-i18n.global<%= IS_DEV ? '.' : '.prod.' %>js"></script>
<script src="//fastly.jsdelivr.net/npm/axios@1.5/dist/axios.min.js"></script>
<script src="//fastly.jsdelivr.net/npm/vant@4.6/lib/vant.min.js"></script>
<script src="//fastly.jsdelivr.net/npm/@tensorflow/tfjs@4.11/dist/tf.min.js"></script>
<script src="//fastly.jsdelivr.net/npm/@tensorflow/tfjs-backend-webgl@4.11/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
14 changes: 12 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,23 @@ const vueConfig = {
open: false,
proxy: null
},
pwa: {
manifestOptions: {
start_url: '/'
},
workboxOptions: {
maximumFileSizeToCacheInBytes: 9000000 // <---- increasing the file size to cached 9mb
}
},
configureWebpack: {
externals: {
'vue-router': 'VueRouter',
'vue-i18n': 'VueI18n',
vue: 'Vue',
axios: 'axios',
vant: 'vant'
vant: 'vant',
'@tensorflow/tfjs': 'tf',
'@tensorflow/tfjs-backend-webgl': 'tf.backend'
},
plugins: [
require('unplugin-vue-components/webpack')({
Expand Down

0 comments on commit 5c91f20

Please sign in to comment.