prebuild.js 624 B

1234567891011121314151617181920
  1. const fs = require("fs");
  2. // for development purposes we want to have the service-worker.js file
  3. // accessible from the public folder. On build though, we need to compile it
  4. // and CRA expects that file to be in src/ folder.
  5. const moveServiceWorkerScript = () => {
  6. const oldPath = "./public/service-worker.js";
  7. const newPath = "./src/service-worker.js";
  8. fs.rename(oldPath, newPath, (error) => {
  9. if (error) {
  10. throw error;
  11. }
  12. console.info("public/service-worker.js moved to src/");
  13. });
  14. };
  15. // -----------------------------------------------------------------------------
  16. moveServiceWorkerScript();