2021-12-10 14:11:49 +08:00
|
|
|
import { defineConfig } from 'vite'
|
|
|
|
import vue from '@vitejs/plugin-vue'
|
2022-02-28 20:26:41 +08:00
|
|
|
import { resolve } from 'path'
|
2021-12-14 15:53:30 +08:00
|
|
|
import { OUTPUT_DIR } from './build/constant'
|
2022-02-28 20:26:41 +08:00
|
|
|
import viteCompression from 'vite-plugin-compression'
|
2021-12-10 14:11:49 +08:00
|
|
|
|
|
|
|
function pathResolve(dir: string) {
|
2022-02-28 20:26:41 +08:00
|
|
|
return resolve(process.cwd(), '.', dir)
|
2021-12-10 14:11:49 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
export default defineConfig({
|
2022-02-28 20:26:41 +08:00
|
|
|
base: './',
|
2021-12-10 14:11:49 +08:00
|
|
|
resolve: {
|
|
|
|
alias: [
|
|
|
|
{
|
|
|
|
find: /\/#\//,
|
2022-02-28 20:26:41 +08:00
|
|
|
replacement: pathResolve('types') + '/'
|
2021-12-10 14:11:49 +08:00
|
|
|
},
|
|
|
|
{
|
|
|
|
find: '@',
|
2022-02-28 20:26:41 +08:00
|
|
|
replacement: pathResolve('src') + '/'
|
2021-12-10 14:11:49 +08:00
|
|
|
}
|
|
|
|
],
|
2022-02-28 20:26:41 +08:00
|
|
|
dedupe: ['vue']
|
2021-12-10 14:11:49 +08:00
|
|
|
},
|
|
|
|
css: {
|
|
|
|
preprocessorOptions: {
|
|
|
|
scss: {
|
|
|
|
javascriptEnabled: true,
|
2022-02-28 20:26:41 +08:00
|
|
|
additionalData: `@import "src/styles/common/style.scss";`
|
|
|
|
}
|
|
|
|
}
|
2021-12-10 14:11:49 +08:00
|
|
|
},
|
|
|
|
plugins: [
|
2022-02-28 20:26:41 +08:00
|
|
|
vue(),
|
|
|
|
viteCompression({
|
|
|
|
verbose: true,
|
|
|
|
disable: false,
|
|
|
|
threshold: 10240,
|
|
|
|
algorithm: 'gzip',
|
|
|
|
ext: '.gz'
|
|
|
|
})
|
2021-12-10 14:11:49 +08:00
|
|
|
],
|
|
|
|
build: {
|
|
|
|
target: 'es2015',
|
|
|
|
outDir: OUTPUT_DIR,
|
|
|
|
terserOptions: {
|
|
|
|
compress: {
|
|
|
|
keep_infinity: true,
|
2022-02-28 20:26:41 +08:00
|
|
|
drop_console: true,
|
|
|
|
drop_debugger: true
|
|
|
|
}
|
|
|
|
},
|
|
|
|
rollupOptions: {
|
|
|
|
output: {
|
|
|
|
chunkFileNames: 'static/js/[name]-[hash].js',
|
|
|
|
entryFileNames: 'static/js/[name]-[hash].js',
|
|
|
|
assetFileNames: 'static/[ext]/[name]-[hash].[ext]'
|
|
|
|
}
|
2021-12-10 14:11:49 +08:00
|
|
|
},
|
|
|
|
brotliSize: false,
|
2022-02-28 20:26:41 +08:00
|
|
|
chunkSizeWarningLimit: 2000
|
|
|
|
}
|
|
|
|
})
|