1 Star 0 Fork 0

yuanzx/tuitao

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
vite.config.ts 2.40 KB
一键复制 编辑 原始数据 按行查看 历史
yuanzx 提交于 2023-08-28 15:35 . init
import path from 'path'
import { defineConfig } from 'vite'
import vue from '@vitejs/plugin-vue'
import Components from 'unplugin-vue-components/vite'
import { ElementPlusResolver } from 'unplugin-vue-components/resolvers'
import Unocss from 'unocss/vite'
import {
presetAttributify,
presetIcons,
presetUno,
transformerDirectives,
transformerVariantGroup,
} from 'unocss'
const pathSrc = path.resolve(__dirname, 'src')
// https://vitejs.dev/config/
export default defineConfig({
resolve: {
alias: {
'@': `${pathSrc}/`,
},
},
server:{
host:'0.0.0.0',
port:8080,
https:false,
open:true
},
css: {
preprocessorOptions: {
scss: {
additionalData: `@use "@/styles/element/index.scss" as *;`,
},
},
},
plugins: [
vue(),
Components({
// allow auto load markdown components under `./src/components/`
extensions: ['vue', 'md'],
// allow auto import and register components used in markdown
include: [/\.vue$/, /\.vue\?vue/, /\.md$/],
resolvers: [
ElementPlusResolver({
importStyle: 'sass',
}),
],
dts: 'src/components.d.ts',
}),
// https://github.com/antfu/unocss
// see unocss.config.ts for config
Unocss({
presets: [
presetUno(),
presetAttributify(),
presetIcons({
scale: 1.2,
warn: true,
}),
],
transformers: [
transformerDirectives(),
transformerVariantGroup(),
]
}),
],
build: {
rollupOptions: {
output: {
manualChunks(id) {
if (id.includes('node_modules')) {
// console.log(namespace,'node_modules',id.toString().split('node_modules/')[1].split('/')[0])
return id.toString().split('node_modules/')[1].split('/')[0]
/**
* BUG vite 打包出现Uncaught ReferenceError: Cannot access 'N' before initialization
* 具体看vite官网https://cn.vitejs.dev/guide/,如何打包组件
*/
// } else if (id.includes('src/components')) {
// console.log(namespace,'src/components',id.includes('src/components'))
// console.log(namespace,'components',id.includes('components'))
// console.log(namespace,'id',id)
// return 'components'
} else {
return 'common'
}
}
}
}
}
})
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/yzxazj/tuitao.git
git@gitee.com:yzxazj/tuitao.git
yzxazj
tuitao
tuitao
master

搜索帮助