generated from sonofmagic/uni-app-vite-vue3-tailwind-vscode-template
-
Notifications
You must be signed in to change notification settings - Fork 0
/
vite.config.ts
28 lines (27 loc) · 885 Bytes
/
vite.config.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
import { defineConfig } from "vite";
import uni from "@dcloudio/vite-plugin-uni";
import commonjs from "@rollup/plugin-commonjs";
const isH5 = process.env.UNI_PLATFORM === "h5";
import vwt from 'weapp-tailwindcss-webpack-plugin/vite';
import postcssWeappTailwindcssRename from 'weapp-tailwindcss-webpack-plugin/postcss';
const postcssPlugins = [require("autoprefixer")(), require("tailwindcss")()];
if (!isH5) {
postcssPlugins.push(
require("postcss-rem-to-responsive-pixel")({
rootValue: 32,
propList: ["*"],
transformUnit: "rpx",
})
);
postcssPlugins.push(postcssWeappTailwindcssRename());
}
// https://vitejs.dev/config/
export default defineConfig({
plugins: [commonjs(), uni(), isH5 ? undefined : vwt()],
// 假如 postcss.config.js 不起作用,请使用内联 postcss
css: {
postcss: {
plugins: postcssPlugins,
},
},
});