53 lines
1.1 KiB
JavaScript
53 lines
1.1 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
|
|
})
|
|
],
|
|
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))
|
|
}
|
|
}
|
|
}) |