Browse Source

vite更改@别名跳转配置

tianyabing 2 years ago
parent
commit
e3d828c1e7
1 changed files with 6 additions and 7 deletions
  1. 6 7
      vite.config.js

+ 6 - 7
vite.config.js

@@ -1,5 +1,3 @@
-import { URL, fileURLToPath } from 'node:url'
-
 import { defineConfig } from 'vite'
 import legacy from '@vitejs/plugin-legacy'
 import vue2 from '@vitejs/plugin-vue2'
@@ -14,6 +12,7 @@ import { ElementUiResolver } from "unplugin-vue-components/resolvers";
 import viteCompression from 'vite-plugin-compression'
 import visualizer from 'rollup-plugin-visualizer'
 import antdvFix from 'vite-plugin-antdv-fix';
+import * as path from "path";
 
 export default defineConfig(({ command }) => {
   return {
@@ -51,15 +50,15 @@ export default defineConfig(({ command }) => {
     },
     resolve: {
       alias: {
-        '@/': new URL('./src/', import.meta.url).pathname,
+        '@': path.resolve(__dirname, './src'),
       },
     },
     plugins: [
       vue2(),
-      //legacy({
-      //  targets: ['ie >= 11'],
-      //  additionalLegacyPolyfills: ['regenerator-runtime/runtime'],
-      //}),
+      legacy({
+        targets: ['ie >= 11'],
+        additionalLegacyPolyfills: ['regenerator-runtime/runtime'],
+      }),
       AutoImport({
         imports: [
           'vue',