123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146 |
- import { defineConfig } from "vite";
- import vue from "@vitejs/plugin-vue";
- import Components from "unplugin-vue-components/vite";
- import { NaiveUiResolver } from "unplugin-vue-components/resolvers";
- import AutoImport from "unplugin-auto-import/vite";
- import legacy from "@vitejs/plugin-legacy";
- import vueJsx from "@vitejs/plugin-vue-jsx";
- import obfuscator from "rollup-plugin-obfuscator";
- const SERVER_URL = "https://192.168.10.39";
- const path = require("path");
- const disableObfuse = process.env.DISABLE_OBFUSE;
- // console.log(disableObfuse);
- console.log("process.env.DISABLE_OBFUSE: ", disableObfuse);
- // https://vitejs.dev/config/
- export default defineConfig({
- base: "/oe-web/",
- plugins: [
- vue({ reactivityTransform: true }),
- vueJsx({}),
- Components({
- resolvers: [NaiveUiResolver()],
- dts: "src/types/components.d.ts",
- }),
- AutoImport({
- // targets to transform
- include: [
- /\.[tj]sx?$/, // .ts, .tsx, .js, .jsx
- /\.vue$/,
- /\.vue\?vue/, // .vue
- ],
- resolvers: [(name) => name === "logger" && "@/utils/logger"],
- dts: "src/types/auto-imports.d.ts",
- // Generate corresponding .eslintrc-auto-import.json file.
- // eslint globals Docs - https://eslint.org/docs/user-guide/configuring/language-options#specifying-globals
- eslintrc: {
- enabled: true, // Default `false`
- filepath: "./.eslintrc-auto-import.json", // Default `./.eslintrc-auto-import.json`
- globalsPropValue: true, // Default `true`, (true | false | 'readonly' | 'readable' | 'writable' | 'writeable')
- },
- }),
- obfuscator({
- // 不同的构建可能成功运行也可能不成功?
- fileOptions: {
- optionsPreset: "low-obfuscation",
- debugProtection: false,
- transformObjectKeys: false,
- disableConsoleOutput: false,
- // deadCodeInjectionThreshold: 0.4,
- controlFlowFlattening: true,
- controlFlowFlatteningThreshold: 0.9,
- // per-file:
- deadCodeInjection: true,
- deadCodeInjectionThreshold: 1,
- // stringArrayThreshold: 1,
- // numbersToExpressions: true,
- // controlFlowFlatteningThreshold: 1,
- // stringArrayCallsTransform: true,
- // stringArrayCallsTransformThreshold: 1,
- // stringArrayEncoding: ["rc4"],
- },
- globalOptions: {
- optionsPreset: "low-obfuscation",
- // debugProtection: true,
- // debugProtectionInterval: 2000,
- domainLock: [
- ".exam-cloud.cn",
- ".test41v3.qmth.com.cn",
- ".ecs.qmth.com.cn",
- ],
- selfDefending: true,
- // sourceMap: false,
- splitStrings: true,
- // // stringArrayCallsTransform: true,
- // deadCodeInjection: true,
- // numbersToExpressions: true,
- // controlFlowFlattening: true,
- // stringArrayEncoding: ["none", "base64", "rc4"],
- // stringArrayRotate: true,
- // transformObjectKeys: true,
- },
- include: [
- "**/utils/encDec.ts",
- "**/UserLogin/**.ts",
- "**/Examing/**/**.ts",
- ],
- exclude: ["node_modules/**"],
- ...(disableObfuse
- ? {
- fileOptions: false,
- globalOptions: false,
- }
- : {}),
- }),
- legacy({
- targets: ["chrome >= 58"],
- additionalLegacyPolyfills: ["regenerator-runtime/runtime"],
- }),
- ],
- server: {
- port: 3000,
- // strictPort: true,
- fs: {
- strict: true,
- allow: ["./"],
- },
- proxy: {
- "/api": {
- target: SERVER_URL,
- changeOrigin: true,
- secure: false,
- ws: true,
- },
- "/admin": {
- target: SERVER_URL,
- changeOrigin: true,
- secure: false,
- },
- },
- },
- resolve: {
- alias: [{ find: "@", replacement: path.resolve(__dirname, "./src") }],
- extensions: [
- ".js",
- ".mjs",
- ".ts",
- ".tsx",
- ".vue",
- ".json",
- ".scss",
- ".css",
- ],
- },
- build: {
- ssr: false,
- // FIXME: 为初期测试开启的调试
- sourcemap: !!disableObfuse,
- target: ["chrome58"],
- },
- // define: {
- // __VUE_PROD_DEVTOOLS__: true, // no effect
- // },
- });
|