2024-06-25 10:27:51 +08:00
|
|
|
|
import { defineConfig } from 'vite'
|
|
|
|
|
import uni from '@dcloudio/vite-plugin-uni'
|
|
|
|
|
import UniPages from '@uni-helper/vite-plugin-uni-pages'
|
|
|
|
|
import UnoCSS from 'unocss/vite'
|
2024-07-02 09:26:16 +08:00
|
|
|
|
import zipPack from "vite-plugin-zip-pack"
|
|
|
|
|
import dayjs from "dayjs";
|
2024-08-13 14:40:19 +08:00
|
|
|
|
import vitePluginRemoveDir from './vite.plugin'; // 自己写的删除插件
|
2024-06-25 10:27:51 +08:00
|
|
|
|
|
2024-08-13 14:40:19 +08:00
|
|
|
|
import getPages from './custom.page'
|
2024-11-14 18:12:00 +08:00
|
|
|
|
import { preprocessCSS } from 'vite'
|
2024-07-10 17:59:21 +08:00
|
|
|
|
const {exclude} = getPages();
|
|
|
|
|
const excludeStaticModule = exclude.filter(item => item.indexOf('.vue') === -1)
|
2024-06-25 10:27:51 +08:00
|
|
|
|
|
2024-07-10 17:59:21 +08:00
|
|
|
|
const timeStringNow = dayjs().format("MM-DD HH-mm-ss")
|
2024-07-02 09:26:16 +08:00
|
|
|
|
|
2024-07-08 15:13:35 +08:00
|
|
|
|
|
2024-07-02 09:26:16 +08:00
|
|
|
|
export default defineConfig(({ command, mode }) => {
|
|
|
|
|
const { UNI_PLATFORM } = process.env // 得到 mp-weixin, h5, app 等
|
|
|
|
|
return {
|
|
|
|
|
plugins: [
|
|
|
|
|
UniPages({
|
|
|
|
|
exclude: ['**/components/**/**.*',...exclude],
|
|
|
|
|
routeBlockLang: 'json5', // 虽然设了默认值,但是vue文件还是要加上 lang="json5", 这样才能很好地格式化
|
|
|
|
|
// homePage 通过 vue 文件的 route-block 的type="home"来设定
|
|
|
|
|
// pages 目录为 src/pages,分包目录不能配置在pages目录下
|
|
|
|
|
// subPackages: ['src/pages-sub'], // 是个数组,可以配置多个,但是不能为pages里面的目录
|
|
|
|
|
}),
|
|
|
|
|
uni(),
|
2024-07-10 17:59:21 +08:00
|
|
|
|
vitePluginRemoveDir({dirName:excludeStaticModule}),
|
2024-07-02 09:26:16 +08:00
|
|
|
|
UnoCSS(),
|
2024-07-09 17:43:44 +08:00
|
|
|
|
zipPack({
|
|
|
|
|
inDir: `dist/build/${UNI_PLATFORM}`, // 输入的文件夹,就是要打包的文件夹
|
|
|
|
|
outDir: `dist/build`, // 打包好的 zip 文件放到哪个文件夹下
|
|
|
|
|
outFileName: `${UNI_PLATFORM}-${timeStringNow}.zip`, //文件名不能包含\/:*?"<>|
|
|
|
|
|
pathPrefix: ''
|
|
|
|
|
}),
|
2024-08-13 14:40:19 +08:00
|
|
|
|
],
|
|
|
|
|
esbuild: {
|
2024-10-29 10:02:45 +08:00
|
|
|
|
// drop: ["console", "debugger"], //打包去掉console,debugger
|
2024-08-13 14:40:19 +08:00
|
|
|
|
},
|
2024-11-14 18:12:00 +08:00
|
|
|
|
//ycysp css变量配置
|
|
|
|
|
css:{
|
|
|
|
|
preprocessorOptions:{
|
|
|
|
|
scss:{
|
|
|
|
|
additionalData: `@use "src/styles/variables.scss" as *;`
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
2024-07-02 09:26:16 +08:00
|
|
|
|
}
|
|
|
|
|
})
|