# viteStudy **Repository Path**: yao_yu/vite-study ## Basic Information - **Project Name**: viteStudy - **Description**: vite学习 - **Primary Language**: JavaScript - **License**: MIT - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 0 - **Created**: 2023-12-06 - **Last Updated**: 2023-12-06 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README ## [多页面应用模式](https://vitejs.cn/guide/build.html#multi-page-app) 假设你有下面这样的项目文件结构 ``` ├── package.json ├── vite.config.js ├── index.html ├── main.js └── nested ├── index.html └── nested.js ``` 在开发过程中,简单地导航或链接到 `/nested/` - 将会按预期工作,与正常的静态文件服务器表现一致。 在构建过程中,你只需指定多个 `.html` 文件作为入口点即可: ``` // vite.config.js const { resolve } = require('path') const { defineConfig } = require('vite') module.exports = defineConfig({ build: { rollupOptions: { input: { main: resolve(__dirname, 'index.html'), nested: resolve(__dirname, 'nested/index.html') } } } }) ``` 如果你指定了另一个根目录,请记住,在解析输入路径时,`__dirname` 的值将仍然是 vite.config.js 文件所在的目录。因此,你需要把对应入口文件的 `root` 的路径添加到 `resolve` 的参数中。 ## 代码混淆 ```js import obfuscator from "rollup-plugin-obfuscator"; { rollupOptions: { plugins: [ obfuscator({ // 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, }), ], }, }, ```