Files
huangguo_landpage/vite.config.js
T
2026-10-21 11:16:51 +07:00

53 lines
1.3 KiB
JavaScript
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
import { defineConfig } from 'vite'
import AutoImport from 'unplugin-auto-import/vite';
import vue from '@vitejs/plugin-vue'
import path from 'path';
// 新落地页移动端样式按 375 设计稿写 px,这里统一转 rem(根字号见 main.js:width/7.5,375 宽时 1rem=50px)
const landingPx2Rem = () => ({
postcssPlugin: 'landing-hg2-px2rem',
Declaration(decl) {
const file = (decl.source && decl.source.input && decl.source.input.file) || ''
if (!file.includes('landing-hg2/Mobile.vue')) return
if (!/\d*\.?\d+px/.test(decl.value)) return
decl.value = decl.value.replace(/(-?\d*\.?\d+)px/g, (m, n) => {
const v = parseFloat(n)
if (!v || Math.abs(v) < 0.5) return m
return +(v / 50).toFixed(5) + 'rem'
})
},
})
landingPx2Rem.postcss = true
export default defineConfig({
plugins: [vue(),AutoImport({
imports: [
'vue',
'vue-router',
],
})],
css: {
postcss: {
plugins: [landingPx2Rem()],
},
},
resolve: {
alias: {
'~': path.resolve(__dirname, 'src'),
},
},
server: {
host: true,
port: 3000,
proxy: {
// 业务接口:/plm/okn/ijb/* → https://d10vry7axuojk2.cloudfront.net/plm/okn/ijb/*
'/plm': {
target: 'https://d10vry7axuojk2.cloudfront.net',
ws: false,
changeOrigin: true,
},
},
},
})