vite.config.extend.js 750 B

1234567891011121314151617181920212223242526272829
  1. import fs from "node:fs";
  2. import path from "node:path";
  3. import { ResolvedConfig } from "vite";
  4. let ViteConfitExtendOptions={
  5. indexPath: ''
  6. }
  7. export default function viteConfitExtend(options) {
  8. let _config= ResolvedConfig;
  9. const _options = options;
  10. return {
  11. name: "index-path-extend",
  12. configResolved(config) {
  13. _config = config;
  14. },
  15. closeBundle() {
  16. if (_config.command == "build" && _options) {
  17. if (_options.indexPath) {
  18. fs.renameSync(
  19. path.resolve(_config.root, _config.build.outDir, "index.html"),
  20. path.resolve(_config.root, _config.build.outDir, _options.indexPath)
  21. );
  22. console.warn(`indexPath: ${_options.indexPath}`);
  23. }
  24. }
  25. },
  26. };
  27. }