longyvfengyun
2024-03-25 4b6b56fc1cbd9f6be12a5bc439e496f29c4b51a1
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
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
import { fileURLToPath, URL } from 'node:url'
 
import { defineConfig } from 'vite'
import vue from '@vitejs/plugin-vue'
 
// 引入等比适配插件
const px2rem = require('postcss-px2rem')
 
// 配置基本大小
const postcss = px2rem({
  // 基准大小 baseSize,需要和rem.js中相同
  remUnit: 16
})
 
export default defineConfig({
  base: "./",
  lintOnSave: true,
  plugins: [
    vue(),
  ],
  css: {
    preprocessorOptions: {
      less: {
        charset: false,
        additionalData: '@import "./src/assets/less/index.less";',
      },
    },
    loaderOptions: {
      postcss: {
        plugins: [
          postcss
        ]
      }
    }
  },
  server: {
    port: 8081,
    host: '0.0.0.0'
  },
  resolve: {
    alias: {
      '@': fileURLToPath(new URL('./src', import.meta.url))
    }
  },
})