generate-offline-config.js 613 B

12345678910111213141516171819
  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 scenePath = scene ? '/' + scene : '';
  8. const configContent = `{
  9. "files": ["build${scenePath}/js/*.js", "build${scenePath}/data/*.json"],
  10. "from": "https://super.4dage.com",
  11. "to": "."
  12. }`;
  13. fs.writeFileSync(`${_dirname}/offline-replace-config.json`, configContent, 'utf-8');
  14. console.log(`offline-replace-config.json 已生成,场景: ${scene}`);