fix(vite): better obfuscate
This commit is contained in:
+34
-28
@@ -1,31 +1,37 @@
|
||||
import { fileURLToPath, URL } from 'node:url'
|
||||
import { defineConfig, loadEnv } from 'vite'
|
||||
import vue from '@vitejs/plugin-vue'
|
||||
import vueDevTools from 'vite-plugin-vue-devtools'
|
||||
import { plugin as mdPlugin, Mode } from 'vite-plugin-markdown'
|
||||
import { fileURLToPath, URL } from "node:url";
|
||||
import { defineConfig, loadEnv } from "vite";
|
||||
import vue from "@vitejs/plugin-vue";
|
||||
import vueDevTools from "vite-plugin-vue-devtools";
|
||||
import { plugin as mdPlugin, Mode } from "vite-plugin-markdown";
|
||||
import obfuscatorPlugin from "vite-plugin-javascript-obfuscator";
|
||||
|
||||
import articlesConfig from './articles/config.json'
|
||||
import articlesConfig from "./articles/config.json";
|
||||
|
||||
// https://vite.dev/config/
|
||||
export default ({ mode }: { mode: string }) => {
|
||||
process.env = { ...process.env, ...loadEnv(mode, process.cwd()) }
|
||||
process.env = { ...process.env, ...loadEnv(mode, process.cwd()) };
|
||||
|
||||
process.env.VITE_BASE_URL = articlesConfig.base_url
|
||||
process.env.VITE_APP_TITLE = articlesConfig.title
|
||||
process.env.VITE_APP_TITLE_NO_HTML = articlesConfig.title.replace(/(<([^>]+)>)/gi, '').trim()
|
||||
process.env.VITE_APP_LANG = articlesConfig.lang
|
||||
process.env.VITE_CUSTOM_HEAD = articlesConfig.custom_head
|
||||
process.env.VITE_BASE_URL = articlesConfig.base_url;
|
||||
process.env.VITE_APP_TITLE = articlesConfig.title;
|
||||
process.env.VITE_APP_TITLE_NO_HTML = articlesConfig.title.replace(/(<([^>]+)>)/gi, "").trim();
|
||||
process.env.VITE_APP_LANG = articlesConfig.lang;
|
||||
process.env.VITE_CUSTOM_HEAD = articlesConfig.custom_head;
|
||||
|
||||
return defineConfig({
|
||||
plugins: [vue(), vueDevTools(), mdPlugin({ mode: [Mode.HTML] })],
|
||||
plugins: [
|
||||
vue(),
|
||||
vueDevTools(),
|
||||
mdPlugin({ mode: [Mode.HTML] }),
|
||||
obfuscatorPlugin({ include: [/.*\.md/], options: { splitStrings: true, stringArrayThreshold: 1, } }),
|
||||
],
|
||||
resolve: {
|
||||
alias: {
|
||||
'@': fileURLToPath(new URL('./src', import.meta.url)),
|
||||
'@views': fileURLToPath(new URL('./src/views', import.meta.url)),
|
||||
'@lib': fileURLToPath(new URL('./src/lib', import.meta.url)),
|
||||
'@articles': fileURLToPath(new URL('./articles', import.meta.url)),
|
||||
'@interfaces': fileURLToPath(new URL('./src/interfaces.ts', import.meta.url)),
|
||||
'@components': fileURLToPath(new URL('./src/components', import.meta.url)),
|
||||
"@": fileURLToPath(new URL("./src", import.meta.url)),
|
||||
"@views": fileURLToPath(new URL("./src/views", import.meta.url)),
|
||||
"@lib": fileURLToPath(new URL("./src/lib", import.meta.url)),
|
||||
"@articles": fileURLToPath(new URL("./articles", import.meta.url)),
|
||||
"@interfaces": fileURLToPath(new URL("./src/interfaces.ts", import.meta.url)),
|
||||
"@components": fileURLToPath(new URL("./src/components", import.meta.url)),
|
||||
},
|
||||
},
|
||||
build: {
|
||||
@@ -34,13 +40,13 @@ export default ({ mode }: { mode: string }) => {
|
||||
codeSplitting: {
|
||||
groups: [
|
||||
{
|
||||
name: (moduleId: string) => moduleId.includes('node_modules') ? 'libs' : 'app',
|
||||
name: (moduleId: string) => (moduleId.includes("node_modules") ? "libs" : "app"),
|
||||
maxSize: 1024 * 1024,
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
},
|
||||
],
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
});
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user