42 lines
1.0 KiB
JavaScript
42 lines
1.0 KiB
JavaScript
import path from "path";
|
|
import {fileURLToPath, URL} from 'node:url'
|
|
import { defineConfig } from 'vite'
|
|
import uni from '@dcloudio/vite-plugin-uni'
|
|
import { UnifiedViteWeappTailwindcssPlugin as uvwt } from "weapp-tailwindcss/vite";
|
|
// 注意: 打包成 h5 和 app 都不需要开启插件配置
|
|
const isH5 = process.env.UNI_PLATFORM === "h5";
|
|
const isApp = process.env.UNI_PLATFORM === "app";
|
|
const weAppTailwindcssDisabled = isH5 || isApp;
|
|
const resolve = (p) => {
|
|
return path.resolve(__dirname, p);
|
|
};
|
|
// https://vitejs.dev/config/
|
|
export default defineConfig({
|
|
build:{
|
|
|
|
},
|
|
plugins: [
|
|
uni(),
|
|
uvwt({
|
|
rem2rpx: true,
|
|
disabled: weAppTailwindcssDisabled
|
|
})
|
|
],
|
|
css: {
|
|
postcss: {
|
|
plugins: [
|
|
require("tailwindcss")({
|
|
// 注意此处,手动传入 `tailwind.config.js` 的绝对路径
|
|
config: resolve("./tailwind.config.js"),
|
|
}),
|
|
require("autoprefixer"),
|
|
]
|
|
},
|
|
},
|
|
resolve: {
|
|
alias: {
|
|
'@': fileURLToPath(new URL('./src', import.meta.url))
|
|
}
|
|
}
|
|
})
|