diff --git a/.env.production b/.env.production index a0bdfb7f..a2e42da7 100644 --- a/.env.production +++ b/.env.production @@ -2,7 +2,7 @@ VITE_USE_MOCK = true # public path -VITE_PUBLIC_PATH = / +VITE_PUBLIC_PATH = ./ # Delete console VITE_DROP_CONSOLE = true diff --git a/.github/workflows/ftp-schedule.yml b/.github/workflows/ftp-schedule.yml deleted file mode 100644 index ad9d08c9..00000000 --- a/.github/workflows/ftp-schedule.yml +++ /dev/null @@ -1,55 +0,0 @@ -# name: schedule-push-to-ftp - -# # Timed deployment project -# on: -# push: -# schedule: -# - cron: '0 20 * * *' - -# jobs: -# schedule-push-to-ftp: -# runs-on: ubuntu-latest -# steps: -# - name: Checkout -# uses: actions/checkout@v2 - -# - name: Sed Config Base -# shell: bash -# run: | -# sed -i 's#VITE_PUBLIC_PATH\s*=.*#VITE_PUBLIC_PATH = /next/#g' ./.env.production -# sed -i "s#VITE_BUILD_COMPRESS\s*=.*#VITE_BUILD_COMPRESS = 'gzip'#g" ./.env.production -# cat ./.env.production - -# - name: use Node.js 14 -# uses: actions/setup-node@v2.1.2 -# with: -# node-version: '14.x' - -# - name: Get yarn cache -# id: yarn-cache -# run: echo "::set-output name=dir::$(yarn cache dir)" - -# - name: Cache dependencies -# uses: actions/cache@v2 -# with: -# path: ${{ steps.yarn-cache.outputs.dir }} -# key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }} -# restore-keys: | -# ${{ runner.os }}-yarn- - -# - name: Build -# run: | -# yarn install -# yarn run build - -# - name: Deploy -# uses: SamKirkland/FTP-Deploy-Action@2.0.0 -# env: -# FTP_SERVER: ${{ secrets.FTP_SERVER }} -# FTP_USERNAME: ${{ secrets.FTP_USERNAME }} -# FTP_PASSWORD: ${{ secrets.FTP_PASSWORD }} -# METHOD: sftp -# PORT: ${{ secrets.FTP_PORT }} -# LOCAL_DIR: dist -# REMOTE_DIR: /srv/www/vben-admin -# ARGS: --delete --verbose --parallel=80 diff --git a/build/script/startElectron.ts b/build/script/startElectron.ts index b339ebbb..b7ee8e45 100644 --- a/build/script/startElectron.ts +++ b/build/script/startElectron.ts @@ -1,14 +1,22 @@ import { createServer } from 'vite'; import path from 'path'; import { startCompilerElectron } from './compilerElectron'; +import minimist from 'minimist'; (async () => { - const server = await createServer({ - root: path.resolve(__dirname, '../../'), - }); + const argv = minimist(process.argv.slice(2)); + console.log(argv); + const isDev = argv.env === 'development'; + let port: number | undefined = undefined; + if (isDev) { + const server = await createServer({ + root: path.resolve(__dirname, '../../'), + }); + + const app = await server.listen(); + port = app.config.server.port; + process.env.PORT = `${port}`; + } - const app = await server.listen(); - const port = app.config.server.port; startCompilerElectron(port); - process.env.PORT = `${port}`; })(); diff --git a/electron-main/index.ts b/electron-main/index.ts index c27a9426..0846b48c 100644 --- a/electron-main/index.ts +++ b/electron-main/index.ts @@ -27,7 +27,7 @@ class createWin { }); const URL = is_dev ? `http://localhost:${process.env.PORT}` // vite 启动的服务器地址 - : `file://${join(__dirname, '../dist/render/index.html')}`; // vite 构建后的静态文件地址 + : `file://${join(__dirname, '../index.html')}`; // vite 构建后的静态文件地址 mainWindow.loadURL(URL); diff --git a/package.json b/package.json index 424a0865..97d89421 100644 --- a/package.json +++ b/package.json @@ -54,7 +54,7 @@ "build": "vite build && esno ./build/script/postBuild.ts", "build:no-cache": "yarn clean:cache && npm run build", "dev:app": "esno ./build/script/startElectron.ts --env=development --watch", - "build:app": "npm run build && esno ./build/script/startElectron.ts && electron-builder ", + "build:app": "npm run build && esno ./build/script/startElectron.ts --env=production && electron-builder ", "report": "cross-env REPORT=true npm run build", "type:check": "vue-tsc --noEmit --skipLibCheck", "preview": "npm run build && vite preview",