lxf
2025-07-10 1b892c1f989315551f624cd6948c2e36f9abc972
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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
import { defineConfig } from 'vite'
import vue from '@vitejs/plugin-vue'
import path from 'path'
import Components from 'unplugin-vue-components/vite';
import { VantResolver } from 'unplugin-vue-components/resolvers';
import DefineOptions from 'unplugin-vue-define-options/vite';
import { visualizer } from 'rollup-plugin-visualizer'
import legacy from '@vitejs/plugin-legacy';
 
const isVisualizer = process.env.VISUALIZER === 'show'
export default defineConfig({
  base: '',  //H5打包用
  // base: './', // APP打包用
  plugins: [
    vue(),
    Components({
      resolvers: [VantResolver()],
    }),
    DefineOptions(),
    isVisualizer && visualizer({ gzipSize: true }),
    legacy({
      targets: ['defaults', 'not IE 11'],
    }),
  ],
  css: {
    preprocessorOptions: {
      scss: {
        additionalData: `@import "@/assets/css/variable.scss";`
      },
    }
  },
  server: {
    open: true,
    port: 8085,
    hmr: true,
    host: '0.0.0.0',
    proxy: {
      "/api": {
        target: "https://104.233.210.35:8085",
        // target: "http://198.13.39.109:8081",
        changeOrigin: true,
        // rewrite: (path) => path.replace(/^\/wap/, ""),
        secure: false
      },
    },
  },
  resolve: {
    dedupe: [
      'vue'
    ],
    alias: {
      'vue-i18n': 'vue-i18n/dist/vue-i18n.cjs.js',
      "~": path.resolve(__dirname, './'),
      "@": path.resolve(__dirname, 'src'),
    }
  },
  build: {
    assetsDir: "static",
    rollupOptions: {
      input: {
        index: path.resolve(__dirname, "index.html"),
      },
      output: {
        chunkFileNames: 'js/[name]-[hash].js',
        entryFileNames: "js/[name]-[hash].js",
        assetFileNames: "[ext]/name-[hash].[ext]"
      },
    },
  },
  externals:['vue']
})
 
const globalSass = config => {
  const oneOfsMap = config.module.rule('scss').oneOfs.store
  oneOfsMap.forEach(item => {
    item
      .use('sass-resources-loader')
      .loader('sass-resources-loader')
      .options({
        resources: '@/assets/css/init.scss'
      })
      .end()
  });
}