代码拉取完成,页面将自动刷新
同步操作将从 芋道源码/yudao-ui-admin-uniapp 强制同步,此操作会覆盖自 Fork 仓库以来所做的任何修改,且无法恢复!!!
确定后同步将在后台操作,完成时将刷新页面,请耐心等待。
import { defineConfig, loadEnv } from "vite";
import uni from "@dcloudio/vite-plugin-uni";
import { resolve } from "path";
import { readFileSync } from "node:fs";
import VueJsx from "@vitejs/plugin-vue-jsx";
import { networkInterfaces } from "node:os";
import { execSync } from "node:child_process";
// import legacy from '@vitejs/plugin-legacy';
const getLoaclIPV4Address = () => {
const Interfaces = networkInterfaces();
for (let net in Interfaces) {
const inter = Interfaces[net];
if (!inter) continue;
for (let port of inter) {
if (
port.family === "IPv4" &&
!port.internal &&
port.address !== "127.0.0.1"
) {
return port.address;
}
}
}
};
/**
* 配置文件来自 [.env.dev](./.env.dev)
* @param {'dev' | 'prod'} mode
* @returns
*/
const createServerConfig = (mode) => {
if (mode !== "prod") {
const LoaclIPV4Address = getLoaclIPV4Address();
let key: Buffer;
let cert: Buffer;
try {
key = readFileSync(`./${LoaclIPV4Address}-key.pem`);
cert = readFileSync(`./${LoaclIPV4Address}.pem`);
} catch (error) {
// 说明文件不存在,生成对应的证书和密钥
try {
execSync(`mkcert ${LoaclIPV4Address}`);
key = readFileSync(`./${LoaclIPV4Address}-key.pem`);
cert = readFileSync(`./${LoaclIPV4Address}.pem`);
} catch (error) {
/**
* mac: brew install mkcert | mkert 192.168.31.192
* windows: winget mkcert | mkert 192.168.31.192
*/
console.error(
"\x1b[34m" +
"请先安装mkcert " +
" https://github.com/FiloSottile/mkcert" +
"\x1b[39m"
);
console.error(
"\x1b[34m" +
"或者使用其他工具在根目录下生成对应ip的密钥 " +
LoaclIPV4Address +
"\x1b[39m",
"\n"
);
throw error;
}
}
return {
port: 8080,
// h5访问相机权限需要https 可以使用 mkcert在根目录下生成devServer对应ip的证书
https: {
key,
cert,
},
host: "0.0.0.0",
};
} else {
return {};
}
};
export default defineConfig(({ mode }) => {
const env = loadEnv(mode, process.cwd());
return {
plugins: [uni(), VueJsx()],
build: {
// target: "modules",
outDir: "dist",
assetsDir: "assets",
sourcemap: false,
minify: "terser",
chunkSizeWarningLimit: 1000,
cssTarget: "chrome61",
terserOptions: {
compress: {
defaults: false,
arguments: true,
},
mangle: {
keep_classnames: true,
keep_fnames: true,
},
},
},
server: {
watch: {
ignored: ['**/DumpStack.log.tmp']
}
},
esbuild: {
pure: mode === "dev" ? [] : ["console.log", "debugger"],
},
resolve: {
alias: {
"@": resolve(__dirname, "src"),
},
},
define: {
"import.meta.env": env,
},
css: {
modules: {
localsConvention: "camelCase",
scopeBehaviour: "local",
generateScopedName: "[local]_[hash:6]",
},
preprocessorOptions: {
scss: {
silenceDeprecations: ["legacy-js-api", "color-functions"],
},
},
},
};
});
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。