123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126 |
- import { UserConfig, ConfigEnv, loadEnv, defineConfig } from 'vite';
- import postcssPxToViewport8Plugin from 'postcss-px-to-viewport-8-plugin';
- import createPlugins from './vite/plugins';
- import path from 'path';
- export default defineConfig(({ mode, command }: ConfigEnv): UserConfig => {
- const env = loadEnv(mode, process.cwd());
- return {
- // 部署生产环境和开发环境下的URL。
- // 默认情况下,vite 会假设你的应用是被部署在一个域名的根路径上
- // 例如 https://www.ruoyi.vip/。如果应用被部署在一个子路径上,你就需要用这个选项指定这个子路径。例如,如果你的应用被部署在 https://www.ruoyi.vip/admin/,则设置 baseUrl 为 /admin/。
- base: './',
- resolve: {
- alias: {
- '~': path.resolve(__dirname, './'),
- '@': path.resolve(__dirname, './src')
- },
- extensions: ['.mjs', '.js', '.ts', '.jsx', '.tsx', '.json', '.vue']
- },
- // https://cn.vitejs.dev/config/#resolve-extensions
- plugins: createPlugins(env, command === 'build'),
- server: {
- host: '0.0.0.0',
- port: 8050,
- open: true,
- cors: true,
- proxy: {
- [env.VITE_APP_BASE_API]: {
- target: env.VITE_APP_BASE_API,
- //target: 'http://localhost:8086/',
- changeOrigin: true,
- ws: true,
- rewrite: (path) => path.replace(new RegExp('^' + env.VITE_APP_BASE_API), '')
- },
- '/api': {
- // 代理请求之后的请求地址(你的真实接口地址)
- target: 'https://cimweb.zjw.sh.cegn.cn:2007/data-business-prod/',
- //target: 'http://localhost:9250/',
- secure: false,
- // 跨域
- changeOrigin: true,
- rewrite: (path) => path.replace(/^\/api/, '')
- },
- '/projectapi': {
- // 代理请求之后的请求地址(你的真实接口地址)
- target: 'https://cimweb.zjw.sh.cegn.cn:2007/data-business-prod-2/',
- //target: 'http://localhost:9250/',
- secure: false,
- // 跨域
- changeOrigin: true,
- rewrite: (path) => path.replace(/^\/projectapi/, '')
- },
- '/openapi': {
- // 代理请求之后的请求地址(你的真实接口地址)
- target: 'https://cimweb.zjw.sh.cegn.cn:2008/',
- //target: 'http://localhost:9250/',
- secure: false,
- // 跨域
- changeOrigin: true,
- rewrite: (path) => path.replace(/^\/openapi/, '')
- },
- }
- },
- css: {
- preprocessorOptions: {
- scss: {
- additionalData: '@import "./src/styles/variables.scss";',
- javascriptEnabled: true
- }
- },
- postcss: {
- plugins: [
- {
- postcssPlugin: 'internal:charset-removal',
- AtRule: {
- charset: (atRule) => {
- if (atRule.name === 'charset') {
- atRule.remove();
- }
- }
- }
- },
- postcssPxToViewport8Plugin({
- unitToConvert: 'px',
- viewportWidth: 1080,
- unitPrecision: 6,
- propList: ['*'],
- viewportUnit: 'vh',
- fontViewportUnit: 'vh',
- selectorBlackList: [],
- minPixelValue: 1,
- mediaQuery: true,
- replace: true,
- exclude: [/node_modules\/(?!element-plus)/, /views\/dataAssetsManage\/dataClean\/antv6/],
- landscape: false
- }) as any
- ]
- }
- },
- // 预编译
- optimizeDeps: {
- include: [
- 'vue',
- 'vue-router',
- 'pinia',
- 'axios',
- '@vueuse/core',
- 'echarts',
- 'vue-i18n',
- '@vueup/vue-quill',
- 'bpmn-js/lib/Viewer',
- 'bpmn-js/lib/Modeler.js',
- 'bpmn-js-properties-panel',
- 'min-dash',
- 'diagram-js/lib/navigation/movecanvas',
- 'diagram-js/lib/navigation/zoomscroll',
- 'bpmn-js/lib/features/palette/PaletteProvider',
- 'bpmn-js/lib/features/context-pad/ContextPadProvider',
- 'diagram-js/lib/draw/BaseRenderer',
- 'tiny-svg',
- 'image-conversion',
- 'element-plus/es/components/**/css'
- ]
- }
- };
- });
|