代码拉取完成,页面将自动刷新
import { resolve } from 'path'
import { defineConfig } from 'vite'
import viteCompression from 'vite-plugin-compression'
import visualizer from 'rollup-plugin-visualizer'
import vue from '@vitejs/plugin-vue'
import legacy from '@vitejs/plugin-legacy'
import Components from 'unplugin-vue-components/vite'
import {
ArcoResolver,
NaiveUiResolver,
ElementPlusResolver,
VueUseComponentsResolver
} from 'unplugin-vue-components/resolvers'
// https://vitejs.dev/config/
export default defineConfig(({ command }) => {
const assetsDir = 'static'
const config = {
resolve: {
alias: [
{
find: /\/@\//,
replacement: resolve(__dirname, './src') + '/'
}
]
},
build: {
assetsDir,
rollupOptions: {
output: {
entryFileNames: `${assetsDir}/[hash].js`,
chunkFileNames: `${assetsDir}/[hash].js`,
assetFileNames: `${assetsDir}/[hash].[ext]`
}
}
},
server: {
host: '0.0.0.0'
}
}
const plugins = [
vue(),
Components({
deep: true,
resolvers: [
ArcoResolver({
resolveIcons: true
}),
NaiveUiResolver(),
ElementPlusResolver(),
VueUseComponentsResolver()
]
}),
legacy({
targets: ['ie >= 11'],
additionalLegacyPolyfills: [
'unfetch/polyfill/polyfill.mjs', // fetch
'matchmedia-polyfill/matchMedia.addListener', // vue-mq
'regenerator-runtime/runtime' // ie11
]
})
]
if (command === 'build') {
if (process.env.npm_config_report) {
// npm run build --report
// npm_config_report=true yarn build
plugins.push(visualizer({
open: true
}))
}
plugins.push(viteCompression({
algorithm: 'brotliCompress'
}))
}
return {
...config,
plugins
}
})
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。