123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116 |
- import vue from "@vitejs/plugin-vue";
- import { resolve } from "path";
- import { defineConfig } from "vite";
- import legacy from '@vitejs/plugin-legacy';
- import { terser } from 'rollup-plugin-terser';
- // https://vitejs.dev/config/
- const pathResolve = (dir: string): string => {
- return resolve(__dirname, ".", dir);
- };
- const alias: Record<string, string> = {
- "@": pathResolve("src"),
- };
- export default defineConfig({
- plugins: [
- vue(),
- legacy({
- targets: ['chrome 52'],
- additionalLegacyPolyfills: ['regenerator-runtime/runtime'],
- renderLegacyChunks: true,
- polyfills: [
- 'es.symbol',
- 'es.promise',
- 'es.promise.finally',
- 'es/map',
- 'es/set',
- 'es.array.filter',
- 'es.array.for-each',
- 'es.array.flat-map',
- 'es.object.define-properties',
- 'es.object.define-property',
- 'es.object.get-own-property-descriptor',
- 'es.object.get-own-property-descriptors',
- 'es.object.keys',
- 'es.object.to-string',
- 'web.dom-collections.for-each',
- 'esnext.global-this',
- 'esnext.string.match-all'
- ]
- }),
- terser()
- ],
- base: "./",
- css: {
- preprocessorOptions: {
- scss: {
- /**
- * 单行溢出隐藏 @include single-hide();
- *
- * 多行溢出隐藏 @include multi-hide(3);
- *
- * flex布局垂直水平居中 @include flex-center();
- *
- */
- additionalData: `
- @mixin flex-center() {
- display: flex;
- justify-content: center;
- align-items: center;
- }
- @mixin single-hide() {
- overflow: hidden;
- white-space: nowrap;
- text-overflow: ellipsis;
- }
- @mixin multi-hide($num) {
- overflow: hidden;
- display: -webkit-box;
- -webkit-box-orient: vertical;
- -webkit-line-clamp: $num;
- }
- `,
- },
- },
- },
- assetsInclude: ['**/*.TTF', '**/*.otf', 'SourceHanSansCN-Bold.otf', 'SourceHanSansCN-Regular.otf', 'STXINGKA.TTF'],
- server: {
- host: true,
- port: 8989,
- proxy: {
- "/zd-api": {
- target: "https://open.api.luojigou.vip",
- // target: "https://open.test.luojigou.vip",
- changeOrigin: true,
- rewrite: (path) => path.replace(/^\/zd-api/, ""),
- },
- },
- },
- resolve: {
- alias,
- // 使用路径别名时想要省略的后缀名,可以自己 增减
- extensions: [".js", ".json", ".ts", ".vue"],
- },
- esbuild: {
- tsconfigRaw: false
- },
- build:{
- rollupOptions: {
- onwarn(warning, warn) {
- // 忽略所有警告
- return
- }
- },
- reportCompressedSize: false,
- chunkSizeWarningLimit: Infinity,
- }
- // build: {
- // target: 'esnext', // 输出 ESNext 代码
- // minify: false, // 禁用代码压缩
- // terserOptions: {
- // 'compress': false
- // } // 禁用 terser 压缩
- // }
- });
|