vite.config.js 1.62 KB
import { defineConfig } from "vite";
import vue from "@vitejs/plugin-vue";
import vueJsx from "@vitejs/plugin-vue-jsx";
import pxtovw from "postcss-px-to-viewport";
import styleImport, { VantResolve } from "vite-plugin-style-import";
const loder_pxtovw = pxtovw({
  unitToConvert: "px", // 需要转换的单位,默认为"px"
  viewportWidth: 750, //  设计稿的视口宽度
  unitPrecision: 2, // 单位转换后保留的精度
  propList: ["*"], // 能转化为vw的属性列表
  viewportUnit: "vw", //  希望使用的视口单位
  fontViewportUnit: "vw", // 字体使用的视口单位
  selectorBlackList: ["ignore"], // 需要忽略的CSS选择器
  exclude: [/node_module/],
});
import path from "path";
import copy from "rollup-plugin-copy";
export default defineConfig({
  base: "./",
  publicDir: "public",
  server: {
    host: true,
  },
  devServer: {
    port: 9091,
    proxy: {
      "/nvsthird/ptzcontrol": {
        target: "http://52.130.155.147:8888",
        changeOrigin: true,
      },
    },
  },
  plugins: [
    vue(),
    vueJsx(),
    styleImport({
      libs: [
        {
          libraryName: "vant",
          esModule: true,
          resolveStyle: (name) => `vant/es/${name}/style`,
        },
      ],
    }),
  ],
  css: {
    postcss: {
      plugins: [loder_pxtovw],
    },
  },
  resolve: {
    alias: {
      "@": path.resolve(__dirname, "./src"),
      "@s": path.resolve(__dirname, "./src/static"),
    },
  },
  build: {
    assetsDir: "static",
    // rollupOptions:{
    //    plugins:[copy({
    //    targets: [
    //      { src: 'public/*', dest: 'dist/static' }
    //    ]
    //  })]
    // }
  },
});