generate-offline-config.js 548 B

123456789101112131415161718
  1. import { fileURLToPath } from 'node:url';
  2. import { dirname } from 'node:path';
  3. import fs from 'node:fs';
  4. const _filename = fileURLToPath(import.meta.url);
  5. const _dirname = dirname(_filename);
  6. const scene = process.env.VITE_APP_SCENE;
  7. const configContent = `{
  8. "files": "build${scene ? '/' + scene : ''}/js/*.js",
  9. "from": "https://super.4dage.com",
  10. "to": "."
  11. }`;
  12. fs.writeFileSync(`${_dirname}/offline-replace-config.json`, configContent, 'utf-8');
  13. console.log(`offline-replace-config.json 已生成,场景: ${scene}`);