uni-app-wx-study/vite.config.js

53 lines
1.1 KiB
JavaScript
Raw Permalink Normal View History

2024-10-17 13:37:58 +08:00
import path from "path";
2024-11-08 20:22:58 +08:00
import {
fileURLToPath,
URL
} from 'node:url'
import {
defineConfig
} from 'vite'
import uni from '@dcloudio/vite-plugin-uni'
2024-11-08 20:22:58 +08:00
import {
UnifiedViteWeappTailwindcssPlugin as uvwt
} from "weapp-tailwindcss/vite";
2024-10-17 13:37:58 +08:00
// 注意: 打包成 h5 和 app 都不需要开启插件配置
const isH5 = process.env.UNI_PLATFORM === "h5";
const isApp = process.env.UNI_PLATFORM === "app";
const weAppTailwindcssDisabled = isH5 || isApp;
const resolve = (p) => {
2024-11-08 20:22:58 +08:00
return path.resolve(__dirname, p);
2024-10-17 13:37:58 +08:00
};
// https://vitejs.dev/config/
export default defineConfig({
2024-11-08 20:22:58 +08:00
build: {
2024-10-16 17:03:14 +08:00
2024-11-08 20:22:58 +08:00
},
plugins: [
uni(),
uvwt({
rem2rpx: true,
disabled: weAppTailwindcssDisabled
})
],
define: {
__VUE_I18N_FULL_INSTALL__: JSON.stringify(true),
__VUE_I18N_LEGACY_API__: JSON.stringify(false),
__INTLIFY_PROD_DEVTOOLS__: JSON.stringify(false),
},
css: {
postcss: {
plugins: [
require("tailwindcss")({
// 注意此处,手动传入 `tailwind.config.js` 的绝对路径
config: resolve("./tailwind.config.js"),
}),
require("autoprefixer"),
]
},
},
resolve: {
alias: {
'@': fileURLToPath(new URL('./src', import.meta.url))
}
}
})