123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181 |
- 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(process.env);
- // 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" : undefined)],
- 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')
- },
- }),
- legacy({
- targets: ["chrome >= 58"],
- additionalLegacyPolyfills: ["regenerator-runtime/runtime"],
- }),
- // process.env.NODE_ENV === "development"
- // ? {}
- // : // : obfuscator({
- // // 不同的构建可能成功运行也可能不成功?
- // // 看看是不是单个文件做transform,然后对最终文件做renderChunk导致的构建结果不一致
- // fileOptions: false,
- // // fileOptions: {
- // // optionsPreset: "low-obfuscation",
- // // debugProtection: false,
- // // transformObjectKeys: false,
- // // disableConsoleOutput: false,
- // // // 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",
- // // ".ea100.com.cn",
- // // ".ecs.qmth.com.cn",
- // // ".qmth.com.cn",
- // // ".dev39.qmth.com.cn",
- // // ".test41.qmth.com.cn",
- // // ],
- // domainLock: [],
- // // selfDefending: true,
- // // sourceMap: false,
- // // splitStrings: true,
- // disableConsoleOutput: false,
- // // // stringArrayCallsTransform: true,
- // // deadCodeInjection: true,
- // // numbersToExpressions: true,
- // controlFlowFlattening: true,
- // // stringArrayEncoding: ["none", "base64", "rc4"],
- // // stringArrayRotate: true,
- // // transformObjectKeys: true,
- // },
- // include: [
- // // "src/**/**.ts",
- // // "src/**/**.js",
- // "src/utils/**.ts",
- // // "**/UserLogin/**.ts",
- // // "**/Examing/**/**.ts",
- // ],
- // exclude: ["node_modules/**"],
- // ...(disableObfuse
- // ? {
- // fileOptions: false,
- // globalOptions: false,
- // }
- // : {}),
- // }),
- // javascriptObfuscator({
- // compact: true,
- // controlFlowFlattening: true,
- // controlFlowFlatteningThreshold: 1,
- // deadCodeInjection: true,
- // deadCodeInjectionThreshold: 1,
- // debugProtection: true,
- // debugProtectionInterval: 0,
- // disableConsoleOutput: true,
- // identifierNamesGenerator: "hexadecimal",
- // log: false,
- // renameGlobals: false,
- // rotateStringArray: true,
- // selfDefending: true,
- // shuffleStringArray: true,
- // splitStrings: true,
- // splitStringsChunkLength: 10,
- // stringArray: true,
- // stringArrayEncoding: ["rc4"],
- // stringArrayThreshold: 1,
- // transformObjectKeys: true,
- // unicodeEscapeSequence: false,
- // }),
- ],
- 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
- // },
- });
|