build.js 827 B

12345678910111213141516171819202122232425262728293031
  1. #!/usr/bin/env node
  2. const swc = require('@swc/core')
  3. const fs = require('fs');
  4. const path = require('path');
  5. const jsdom = require("jsdom");
  6. const { JSDOM } = jsdom;
  7. const indexJS = fs.readFileSync("./server/public/index.js", 'utf-8');
  8. const indexHTML = fs.readFileSync("./server/public/index.html", 'utf-8');
  9. let productionCode = '';
  10. swc.transform(indexJS, {
  11. // Some options cannot be specified in .swcrc
  12. filename: "index.js",
  13. sourceMaps: true,
  14. // Input files are treated as module by default.
  15. isModule: false,
  16. // All options below can be configured via .swcrc
  17. jsc: {
  18. parser: {
  19. syntax: "ecmascript",
  20. },
  21. transform: {},
  22. },
  23. }).then((output) => {
  24. productionCode = output.code;
  25. // console.log(output.map); // source map (in string)
  26. }).then(() => {
  27. });