You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
|
|
|
import { defineConfig } from 'vite'
|
|
|
|
import uni from '@dcloudio/vite-plugin-uni'
|
|
|
|
import path from 'path'
|
|
|
|
import Unocss from 'unocss/vite'
|
|
|
|
|
|
|
|
// https://vitejs.dev/config/
|
|
|
|
export default defineConfig({
|
|
|
|
plugins: [
|
|
|
|
uni(),
|
|
|
|
// https://github.com/antfu/unocss
|
|
|
|
Unocss()
|
|
|
|
],
|
|
|
|
//静态资源服务的文件夹
|
|
|
|
publicDir: "static",
|
|
|
|
base: './',
|
|
|
|
//静态资源处理
|
|
|
|
assetsInclude: "",
|
|
|
|
server: {
|
|
|
|
port: 81,
|
|
|
|
host: '0.0.0.0',
|
|
|
|
},
|
|
|
|
resolve: {
|
|
|
|
alias: {
|
|
|
|
'@': path.resolve(__dirname, './src'),
|
|
|
|
'@components': path.resolve(__dirname, './src/components')
|
|
|
|
}
|
|
|
|
},
|
|
|
|
css: {
|
|
|
|
// 配置`scss`和`less`全局变量
|
|
|
|
preprocessorOptions: {
|
|
|
|
scss: {
|
|
|
|
additionalData: '@import "@/styles/vars/_base.scss";'
|
|
|
|
},
|
|
|
|
less: {
|
|
|
|
additionalData: '@import "@/styles/vars/_base.less";'
|
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
|
|
|
//打包配置
|
|
|
|
build: {
|
|
|
|
//浏览器兼容性 "esnext"|"modules"
|
|
|
|
target: "modules",
|
|
|
|
//指定输出路径
|
|
|
|
outDir: "dist/build",
|
|
|
|
//生成静态资源的存放路径
|
|
|
|
assetsDir: "static",
|
|
|
|
//小于此阈值的导入或引用资源将内联为 base64 编码,以避免额外的 http 请求。设置为 0 可以完全禁用此项
|
|
|
|
assetsInlineLimit: 4096,
|
|
|
|
//启用/禁用 CSS 代码拆分
|
|
|
|
cssCodeSplit: true,
|
|
|
|
//构建后是否生成 source map 文件
|
|
|
|
sourcemap: false,
|
|
|
|
//当设置为 true,构建后将会生成 manifest.json 文件
|
|
|
|
manifest: false,
|
|
|
|
// 设置为 false 可以禁用最小化混淆,
|
|
|
|
// 或是用来指定使用哪种混淆器
|
|
|
|
// boolean | 'terser' | 'esbuild'
|
|
|
|
minify: "terser", //terser 构建后文件体积更小
|
|
|
|
//传递给 Terser 的更多 minify 选项。
|
|
|
|
terserOptions: {
|
|
|
|
// compress: {
|
|
|
|
// drop_console: true,
|
|
|
|
// },
|
|
|
|
},
|
|
|
|
//设置为 false 来禁用将构建后的文件写入磁盘
|
|
|
|
write: true,
|
|
|
|
//默认情况下,若 outDir 在 root 目录下,则 Vite 会在构建时清空该目录。
|
|
|
|
emptyOutDir: true,
|
|
|
|
//启用/禁用 brotli 压缩大小报告
|
|
|
|
brotliSize: true,
|
|
|
|
//chunk 大小警告的限制
|
|
|
|
chunkSizeWarningLimit: 500
|
|
|
|
},
|
|
|
|
})
|