ci: actions
This commit is contained in:
2
.github/workflows/release.yml
vendored
2
.github/workflows/release.yml
vendored
@@ -38,7 +38,7 @@ jobs:
|
|||||||
- name: Build for file protocol
|
- name: Build for file protocol
|
||||||
run: pnpm build:file
|
run: pnpm build:file
|
||||||
|
|
||||||
- name: Rename dist folders
|
- name: Prepare directories
|
||||||
run: |
|
run: |
|
||||||
mv dist dist-prod
|
mv dist dist-prod
|
||||||
mv dist-prod/index.html dist-prod/404.html
|
mv dist-prod/index.html dist-prod/404.html
|
||||||
|
|||||||
243
vite.config.ts
243
vite.config.ts
@@ -19,132 +19,133 @@ const require = createRequire(import.meta.url)
|
|||||||
const process = require('node:process')
|
const process = require('node:process')
|
||||||
|
|
||||||
export default defineConfig(({ mode }) => {
|
export default defineConfig(({ mode }) => {
|
||||||
const env = loadEnv(mode, __dirname)
|
const env = loadEnv(mode, __dirname)
|
||||||
const chunkName = mode === 'prebuild' ? '[name]' : 'chunk'
|
const chunkName = mode === 'prebuild' ? '[name]' : 'chunk'
|
||||||
|
|
||||||
return {
|
return {
|
||||||
base: mode === 'file' ? './' : '/log-lottery/',
|
base: mode === 'file' ? './' : '/log-lottery/',
|
||||||
plugins: [
|
plugins: [
|
||||||
vue(),
|
vue(),
|
||||||
mode === 'file'
|
mode === 'file'
|
||||||
? legacy({
|
? legacy({
|
||||||
additionalLegacyPolyfills: ['regenerator-runtime/runtime'],
|
additionalLegacyPolyfills: ['regenerator-runtime/runtime'],
|
||||||
})
|
})
|
||||||
: null,
|
: null,
|
||||||
// vueDevTools(),
|
// vueDevTools(),
|
||||||
viteCompression({
|
viteCompression({
|
||||||
verbose: true,
|
verbose: true,
|
||||||
disable: false,
|
disable: false,
|
||||||
threshold: 10240,
|
threshold: 10240,
|
||||||
algorithm: 'gzip',
|
algorithm: 'gzip',
|
||||||
ext: '.gz',
|
ext: '.gz',
|
||||||
}),
|
}),
|
||||||
visualizer({
|
visualizer({
|
||||||
emitFile: true, // 是否被触摸
|
emitFile: true, // 是否被触摸
|
||||||
filename: 'test.html', // 生成分析网页文件名
|
filename: 'test.html', // 生成分析网页文件名
|
||||||
open: true, // 在默认用户代理中打开生成的文件
|
open: true, // 在默认用户代理中打开生成的文件
|
||||||
gzipSize: true, // 从源代码中收集 gzip 大小并将其显示在图表中
|
gzipSize: true, // 从源代码中收集 gzip 大小并将其显示在图表中
|
||||||
brotliSize: true, // 从源代码中收集 brotli 大小并将其显示在图表中
|
brotliSize: true, // 从源代码中收集 brotli 大小并将其显示在图表中
|
||||||
}),
|
}),
|
||||||
|
|
||||||
createSvgIconsPlugin({
|
createSvgIconsPlugin({
|
||||||
// 指定需要缓存的图标文件夹
|
// 指定需要缓存的图标文件夹
|
||||||
iconDirs: [path.resolve(process.cwd(), 'src/icons')],
|
iconDirs: [path.resolve(process.cwd(), 'src/icons')],
|
||||||
// 指定symbolId格式
|
// 指定symbolId格式
|
||||||
symbolId: 'icon-[dir]-[name]',
|
symbolId: 'icon-[dir]-[name]',
|
||||||
}),
|
}),
|
||||||
AutoImport({
|
AutoImport({
|
||||||
resolvers: [
|
resolvers: [
|
||||||
// 自动导入图标组件
|
// 自动导入图标组件
|
||||||
IconsResolver({
|
IconsResolver({
|
||||||
prefix: 'Icon',
|
prefix: 'Icon',
|
||||||
}),
|
}),
|
||||||
|
],
|
||||||
|
dts: path.resolve(path.resolve(__dirname, 'src'), 'auto-imports.d.ts'),
|
||||||
|
}),
|
||||||
|
Components({
|
||||||
|
resolvers: [
|
||||||
|
// 自动注册图标组件
|
||||||
|
IconsResolver({
|
||||||
|
enabledCollections: ['ep'],
|
||||||
|
}),
|
||||||
|
],
|
||||||
|
dts: path.resolve(path.resolve(__dirname, 'src'), 'components.d.ts'),
|
||||||
|
}),
|
||||||
|
Icons({
|
||||||
|
autoInstall: true,
|
||||||
|
}),
|
||||||
],
|
],
|
||||||
dts: path.resolve(path.resolve(__dirname, 'src'), 'auto-imports.d.ts'),
|
css: {
|
||||||
}),
|
preprocessorOptions: {
|
||||||
Components({
|
scss: {
|
||||||
resolvers: [
|
additionalData: '@use "@/style/global.scss" as *;',
|
||||||
// 自动注册图标组件
|
},
|
||||||
IconsResolver({
|
},
|
||||||
enabledCollections: ['ep'],
|
// postcss: {
|
||||||
}),
|
// plugins: [
|
||||||
],
|
// require('tailwindcss'),
|
||||||
dts: path.resolve(path.resolve(__dirname, 'src'), 'components.d.ts'),
|
// require('autoprefixer'),
|
||||||
}),
|
// ]
|
||||||
Icons({
|
// }
|
||||||
autoInstall: true,
|
|
||||||
}),
|
|
||||||
],
|
|
||||||
css: {
|
|
||||||
preprocessorOptions: {
|
|
||||||
scss: {
|
|
||||||
additionalData: '@use "@/style/global.scss" as *;',
|
|
||||||
},
|
},
|
||||||
},
|
server: {
|
||||||
// postcss: {
|
host: 'localhost',
|
||||||
// plugins: [
|
port: 6719,
|
||||||
// require('tailwindcss'),
|
proxy: {
|
||||||
// require('autoprefixer'),
|
'/api': {
|
||||||
// ]
|
target: env.VITE_BASE_URL,
|
||||||
// }
|
// 是否跨域
|
||||||
},
|
changeOrigin: true,
|
||||||
server: {
|
// 路径重写
|
||||||
host: 'localhost',
|
rewrite: path => path.replace(/^\/api/, ''),
|
||||||
port: 6719,
|
},
|
||||||
proxy: {
|
},
|
||||||
'/api': {
|
|
||||||
target: env.VITE_BASE_URL,
|
|
||||||
// 是否跨域
|
|
||||||
changeOrigin: true,
|
|
||||||
// 路径重写
|
|
||||||
rewrite: path => path.replace(/^\/api/, ''),
|
|
||||||
},
|
},
|
||||||
},
|
resolve: {
|
||||||
},
|
alias: {
|
||||||
resolve: {
|
'@': path.resolve(__dirname, './src'),
|
||||||
alias: {
|
},
|
||||||
'@': path.resolve(__dirname, './src'),
|
|
||||||
},
|
|
||||||
},
|
|
||||||
build: {
|
|
||||||
minify: 'terser',
|
|
||||||
terserOptions: {
|
|
||||||
compress: {
|
|
||||||
// 生产环境时移除console
|
|
||||||
drop_console: true,
|
|
||||||
drop_debugger: true,
|
|
||||||
},
|
},
|
||||||
},
|
build: {
|
||||||
// 关闭文件计算
|
outDir: mode === 'file' ? 'dist-file' : 'dist',
|
||||||
reportCompressedSize: false,
|
minify: 'terser',
|
||||||
// 关闭生成map文件 可以达到缩小打包体积
|
terserOptions: {
|
||||||
sourcemap: false, // 这个生产环境一定要关闭,不然打包的产物会很大
|
compress: {
|
||||||
rollupOptions: {
|
// 生产环境时移除console
|
||||||
output: {
|
drop_console: true,
|
||||||
chunkFileNames: `js/${chunkName}-[hash].js`, // 引入文件名的名称
|
drop_debugger: true,
|
||||||
entryFileNames: `js/${chunkName}-[hash].js`, // 包的入口文件名称
|
},
|
||||||
assetFileNames: `[ext]/${chunkName}-[hash].[ext]`, // 资源文件像 字体,图片等
|
},
|
||||||
manualChunks(id: any): string {
|
// 关闭文件计算
|
||||||
if (id.includes('node_modules')) {
|
reportCompressedSize: false,
|
||||||
return id
|
// 关闭生成map文件 可以达到缩小打包体积
|
||||||
.toString()
|
sourcemap: false, // 这个生产环境一定要关闭,不然打包的产物会很大
|
||||||
.split('node_modules/')[1]
|
rollupOptions: {
|
||||||
.split('/')[0]
|
output: {
|
||||||
.toString()
|
chunkFileNames: `js/${chunkName}-[hash].js`, // 引入文件名的名称
|
||||||
}
|
entryFileNames: `js/${chunkName}-[hash].js`, // 包的入口文件名称
|
||||||
},
|
assetFileNames: `[ext]/${chunkName}-[hash].[ext]`, // 资源文件像 字体,图片等
|
||||||
|
manualChunks(id: any): string {
|
||||||
|
if (id.includes('node_modules')) {
|
||||||
|
return id
|
||||||
|
.toString()
|
||||||
|
.split('node_modules/')[1]
|
||||||
|
.split('/')[0]
|
||||||
|
.toString()
|
||||||
|
}
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
},
|
},
|
||||||
},
|
// 使用这个必须在上面加/// <reference types="vitest" /> 不然会有类型报错
|
||||||
},
|
test: {
|
||||||
// 使用这个必须在上面加/// <reference types="vitest" /> 不然会有类型报错
|
globals: true, // --> 0.8.1+ 请修改成globals
|
||||||
test: {
|
environment: 'jsdom',
|
||||||
globals: true, // --> 0.8.1+ 请修改成globals
|
// include: ['**/__tests__/**/*.{js,mjs,cjs,ts,mts,cts,jsx,tsx}'],
|
||||||
environment: 'jsdom',
|
// passWithNoTests: true,
|
||||||
// include: ['**/__tests__/**/*.{js,mjs,cjs,ts,mts,cts,jsx,tsx}'],
|
transformMode: {
|
||||||
// passWithNoTests: true,
|
web: [/\.[jt]sx$/],
|
||||||
transformMode: {
|
},
|
||||||
web: [/\.[jt]sx$/],
|
},
|
||||||
},
|
}
|
||||||
},
|
|
||||||
}
|
|
||||||
})
|
})
|
||||||
|
|||||||
Reference in New Issue
Block a user