student-dx-intelligence-main/vite.config.js

121 lines
4.6 KiB
JavaScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

import {
defineConfig
} from "vite";
import {
loadEnv
} from 'vite';
import copy from 'rollup-plugin-copy';
import vue from "@vitejs/plugin-vue";
import ElementPlus from "unplugin-element-plus/vite";
//import postcsspxtoviewport from 'postcss-px-to-viewport';
import jqueryPlugin from './vite-plugin-jquery';
const {
resolve
} = require("path");
/**
* @type {import('vite').UserConfig}
*/
export default defineConfig(({
command,
mode
}) => {
let vueI18n = {};
if (command === "serve") {
vueI18n["vue-i18n"] = "vue-i18n/dist/vue-i18n.cjs.js"; //解决dev运行警告You are running the esm-bundler build of vue-i18n.
}
return {
plugins: [
vue(),
jqueryPlugin(),
ElementPlus({
useSource: true,
}),
copy({
targets: [
// {
// src: 'node_modules/@easydarwin/easyplayer/dist/component/EasyPlayer-lib.min.js',
// dest: 'public/js'
// },
{
src: 'node_modules/@liveqing/liveplayer-v3/dist/component/liveplayer-lib.min.js',
dest: 'public/js'
},
]
})
],
// base: loadEnv(mode, process.cwd()).opendoorUrl,
resolve: {
alias: {
"~/": `${resolve(__dirname, "src")}/`,
...vueI18n,
'@': resolve('src'),
},
extensions: [
'.mjs',
'.js',
'.ts',
'.jsx',
'.tsx',
'.json',
'.vue'
]
},
// base: "./",
server: {
host: "127.0.0.1",
// host: "192.168.1.105",
port: 8086,
open: true,
https: false, // 开启https服务
// 反向代理
// proxy: {
// "/api": {
// target: "http://192.168.100.96:18000/",
// changeOrigin: true,
// rewrite: (path) => path.replace(/^\/api/, ""),
// },
// },
},
css: {
preprocessorOptions: {
scss: {
additionalData: `@use "@/styles/element/index.scss" as *;`,
},
},
// postcss: {
// plugins: [
// // 需要注意的是include这个属性现在是不能用的
// //postcss-px-to-viewport官方虽然更新了文档介绍include的使用方法但是源码迟迟没有更新
// //所以需要另外再安装一个包也就是先使用github仓库的代码
// // npm i https://github.com/evrone/postcss-px-to-viewport --save-dev
// postcsspxtoviewport({
// // viewportWidth: "1920", //视窗的宽度,对应的是我们设计稿的宽度
// viewportWidth: 1920, //视窗的宽度,对应的是我们设计稿的宽度
// viewportHeight: 968, // 视窗的高度
// //viewportHeight: "750", // 视窗的高度
// unitToConvert: 'px', // 要转化的单位
// // viewportWidth: 750, // UI设计稿的宽度
// unitPrecision: 6, // 转换后的精度,即小数点位数
// propList: ['*'], // 指定转换的css属性的单位*代表全部css属性的单位都进行转换
// viewportUnit: 'vw', // 指定需要转换成的视窗单位默认vw
// fontViewportUnit: 'vw', // 指定字体需要转换成的视窗单位默认vw
// selectorBlackList: ['ignore-'], // 指定不转换为视窗单位的类名,
// minPixelValue: 1, // 默认值1小于或等于1px则不进行转换
// mediaQuery: true, // 是否在媒体查询的css代码中也进行转换默认false
// replace: true, // 是否转换后直接更换属性值
// // exclude: [/node_modules/], // 设置忽略文件,用正则做目录名匹配
// // exclude: [],
// include: [/\/src\/views\/screen\//], //只转换匹配的文件 D:\SKZH\新的科大管控系统后台\brisk-admin-main - pinia\src\views\screen\kqscreen.vue
// landscape: false // 是否处理横屏情况
// })
// ]
// },
//开发过程中是否启sourcemap
devSourcemap: true,
},
};
});