fix:change ci
This commit is contained in:
50
.github/workflows/deploy-aliyun-oss.yml
vendored
Normal file
50
.github/workflows/deploy-aliyun-oss.yml
vendored
Normal file
@@ -0,0 +1,50 @@
|
||||
name: Deploy to GitHub Pages & Aliyun OSS
|
||||
|
||||
on:
|
||||
push:
|
||||
branches: [ 'master' ]
|
||||
workflow_dispatch:
|
||||
|
||||
permissions:
|
||||
contents: read
|
||||
pages: write
|
||||
id-token: write
|
||||
|
||||
concurrency:
|
||||
group: 'deploy'
|
||||
cancel-in-progress: true
|
||||
|
||||
jobs:
|
||||
build:
|
||||
runs-on: ubuntu-latest
|
||||
outputs:
|
||||
build-path: dist
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: Install pnpm
|
||||
uses: pnpm/action-setup@v4
|
||||
with:
|
||||
version: 8
|
||||
|
||||
- name: Set up Node
|
||||
uses: actions/setup-node@v4
|
||||
with:
|
||||
node-version: 24
|
||||
cache: 'pnpm'
|
||||
|
||||
- name: Install dependencies
|
||||
run: pnpm install
|
||||
|
||||
- name: Build
|
||||
run: pnpm run build
|
||||
|
||||
- name: Deploy to OSS + Refresh CDN
|
||||
run: pnpm run deploy-oss
|
||||
env:
|
||||
OSS_KEY_ID: ${{ secrets.OSS_KEY_ID }}
|
||||
OSS_KEY_SECRET: ${{ secrets.OSS_KEY_SECRET }}
|
||||
OSS_BUCKET: ${{ secrets.OSS_BUCKET }}
|
||||
OSS_REGION: ${{ secrets.OSS_REGION }}
|
||||
CDN_DOMAIN: ${{ secrets.CDN_DOMAIN }}
|
||||
11
.github/workflows/deploy-pages.yml
vendored
11
.github/workflows/deploy-pages.yml
vendored
@@ -38,16 +38,7 @@ jobs:
|
||||
run: pnpm install
|
||||
|
||||
- name: Build
|
||||
run: pnpm run build
|
||||
|
||||
- name: Deploy to OSS + Refresh CDN
|
||||
run: pnpm run deploy-oss
|
||||
env:
|
||||
OSS_KEY_ID: ${{ secrets.OSS_KEY_ID }}
|
||||
OSS_KEY_SECRET: ${{ secrets.OSS_KEY_SECRET }}
|
||||
OSS_BUCKET: ${{ secrets.OSS_BUCKET }}
|
||||
OSS_REGION: ${{ secrets.OSS_REGION }}
|
||||
CDN_DOMAIN: ${{ secrets.CDN_DOMAIN }}
|
||||
run: pnpm run build-nocdn
|
||||
|
||||
- name: Upload artifact
|
||||
uses: actions/upload-pages-artifact@v3
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
"dev": "vite",
|
||||
"test": "",
|
||||
"build": "vite build",
|
||||
"build-local": "vite build",
|
||||
"build-nocdn": "vite build",
|
||||
"build-tsc": "vue-tsc && vite build",
|
||||
"report": "vite build",
|
||||
"preview": "vite preview",
|
||||
|
||||
@@ -17,7 +17,7 @@ function pathResolve(dir: string) {
|
||||
}
|
||||
|
||||
const lifecycle = process.env.npm_lifecycle_event;
|
||||
let isBuild = ['build', 'report'].includes(lifecycle)
|
||||
let isCdnBuild = ['build', 'report'].includes(lifecycle)
|
||||
|
||||
// https://vitejs.dev/config/
|
||||
export default defineConfig(() => {
|
||||
@@ -56,7 +56,7 @@ export default defineConfig(() => {
|
||||
open: true //如果存在本地服务端口,将在打包后自动展示
|
||||
}) : null,
|
||||
SlidePlugin(),
|
||||
isBuild ? [
|
||||
isCdnBuild ? [
|
||||
//这里不要用vite-plugin-cdn-import,他里面使用了rollup-plugin-external-globals插件,会导致自动加载components.d.ts里面的组件全部没引入,也不报错
|
||||
{
|
||||
name: 'inject-cdn-head',
|
||||
@@ -80,11 +80,11 @@ export default defineConfig(() => {
|
||||
build: {
|
||||
rollupOptions: {
|
||||
// 因为已经把包复制过来了,里面的axios实例用的项目的,所以这行代码可以不要了
|
||||
// external: isBuild ? ['axios'] : [],// 使用全局的 axios。因为百度翻译库内部用了0.19版本的axios,会被打包到代码里面
|
||||
// external: isCdnBuild ? ['axios'] : [],// 使用全局的 axios。因为百度翻译库内部用了0.19版本的axios,会被打包到代码里面
|
||||
output: {
|
||||
manualChunks(id) {
|
||||
if (id.includes('dialog')) {
|
||||
return 'dialog'
|
||||
if (id.includes('node_modules/@iconify') || id.includes('~icons')) {
|
||||
return 'icons';
|
||||
}
|
||||
if (id.includes('utils')
|
||||
|| id.includes('hooks')
|
||||
@@ -93,8 +93,10 @@ export default defineConfig(() => {
|
||||
) {
|
||||
return 'utils'
|
||||
}
|
||||
if (id.includes('node_modules/@iconify') || id.includes('~icons')) {
|
||||
return 'icons';
|
||||
if (!isCdnBuild) return
|
||||
//不知为何不引入cdn之后,这里分包会报错
|
||||
if (id.includes('dialog')) {
|
||||
return 'dialog'
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user