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.
109 lines
3.8 KiB
109 lines
3.8 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) => {
|
|
console.info('command', configEnv.command);
|
|
console.info('mode', configEnv.mode);
|
|
return {
|
|
server: {
|
|
host: '0.0.0.0',
|
|
port: 3000,
|
|
open: false,
|
|
proxy: {
|
|
'/api': {
|
|
// target: 'http://192.168.10.109:8090/', // 显雨
|
|
// target: 'http://192.168.10.5:4500', // 高玉
|
|
// target: 'http://192.168.10.87:8090', // 罗战
|
|
// target: 'http://192.168.10.93:8090', // 周渺
|
|
// target: 'http://192.168.10.106:8090', // 舒梦娇
|
|
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: true,
|
|
},
|
|
shouldLint: (path) => /\/src\/[^?]*\.(vue|m?[jt]sx?)$/.test(path),
|
|
}),
|
|
enforce: 'post',
|
|
},
|
|
],
|
|
css: {
|
|
preprocessorOptions: {
|
|
less: {
|
|
javascriptEnabled: true,
|
|
},
|
|
},
|
|
},
|
|
};
|
|
};
|