1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374 |
- import { defineConfig } from "vite";
- import vue from "@vitejs/plugin-vue";
- import vueJsx from "@vitejs/plugin-vue-jsx";
- import Components from "unplugin-vue-components/vite";
- import { VantResolver } from "unplugin-vue-components/resolvers";
- import postcssPxtorem from "postcss-pxtorem";
- import { createStyleImportPlugin } from "vite-plugin-style-import";
- import legacy from "@vitejs/plugin-legacy";
- import path from "path";
- const proxyUrl = "https://dev.colexiu.com/";
- // const proxyUrl = "https://online.colexiu.com/";
- const resolve = (dir: string) => path.join(__dirname, dir)
- // https://vitejs.dev/config/
- export default defineConfig({
- base: './',
- plugins: [
- vue(),
- vueJsx(),
- legacy({
- targets: ["> 0.25%, not dead"],
- ignoreBrowserslistConfig: true,
- }),
- Components({
- resolvers: [VantResolver()],
- }),
- createStyleImportPlugin({
- libs: [
- {
- libraryName: "vant",
- esModule: true,
- resolveStyle: (name) => `../es/${name}/style/index`,
- },
- ],
- }),
- ],
- css: {
- postcss: {
- plugins: [
- postcssPxtorem({
- rootValue: 37.5, // 1rem的大小
- propList: ["*"], // 需要转换的属性,这里选择全部都进行转换
- }),
- ],
- },
- },
- resolve: {
- alias: {
- "@": resolve('./src'),
- },
- },
- server: {
- host: "0.0.0.0",
- port: 5050,
- // open: true,
- proxy: {
- "/api-website": {
- target: proxyUrl,
- changeOrigin: true,
- },
- },
- },
- build: {
- terserOptions: {
- //打包后移除console和注释
- compress: {
- drop_console: true,
- drop_debugger: true,
- },
- },
- },
- });
|