You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
shop-admin/vite.config.js

103 lines
3.4 KiB

import eslintPlugin from '@nabla/vite-plugin-eslint';
import globalStyle from '@originjs/vite-plugin-global-style';
import legacy from '@vitejs/plugin-legacy';
import vue from '@vitejs/plugin-vue';
import vueJsx from '@vitejs/plugin-vue-jsx';
import { resolve } from 'path';
import AutoImport from 'unplugin-auto-import/vite';
import { ElementPlusResolver } from 'unplugin-vue-components/resolvers';
import Components from 'unplugin-vue-components/vite';
import removeConsole from 'vite-plugin-remove-console';
import svgLoader from 'vite-svg-loader';
export default (configEnv) => {
return {
build: { outDir: 'cicd/dist' },
server: {
host: '0.0.0.0',
port: 3001,
open: false,
proxy: {
'/api': {
// target: 'https://k8s-horse-gateway.mashibing.cn/', // 测试地址
target: 'https://you-gateway.mashibing.com', // 生产环境
changeOrigin: true,
rewrite: (path) => path.replace(/^\/api/, ''),
},
},
},
resolve: {
alias: [
{
find: '@',
replacement: resolve(process.cwd(), 'src'),
},
{
find: '~',
replacement: resolve(process.cwd(), 'src/assets'),
},
],
},
plugins: [
vue(),
vueJsx({
transformOn: true,
}),
svgLoader(),
AutoImport({
include: [/\.[jt]sx?$/, /\.vue\??/],
imports: [
'vue',
'vuex',
'vue-router',
{
axios: [
['default', 'axios'], // import { default as axios } from 'axios',
],
},
{ lodash: [['*', '_']] },
{ dayjs: [['*', 'dayjs']] },
],
eslintrc: {
enabled: true,
filepath: './src/.eslintrc.json',
globalsPropValue: true,
},
dts: 'src/auto-imports.d.ts',
}),
Components({
// dirs: ['src/components'],
// extensions: ['vue', 'jsx', 'tsx', 'js', 'ts'],
// deep: true,
resolvers: [ElementPlusResolver()],
// dts: 'src/components.d.ts',
// include: [/\.tsx$/, /\.jsx$/, /\.ts$/, /\.js$/, /\.vue$/, /\.vue\?vue/],
// exclude: [/[\\/]node_modules[\\/]/, /[\\/]\.git[\\/]/],
}),
removeConsole(),
globalStyle({
sourcePath: 'src/styles',
}),
legacy({
targets: ['defaults', 'not IE 11', 'chrome 52'],
}),
{
...eslintPlugin({
eslintOptions: {
cache: false,
},
shouldLint: (path) => /\/src\/[^?]*\.(vue|m?[jt]sx?)$/.test(path),
}),
enforce: 'post',
},
],
css: {
preprocessorOptions: {
less: {
javascriptEnabled: true,
},
},
},
};
};