only require babel register on dev

This commit is contained in:
Martina 2021-08-20 13:42:38 -07:00
parent dae49fd767
commit f7bdea0d4a
2 changed files with 30 additions and 28 deletions

View File

@ -1,7 +1,8 @@
const path = require("path"); const path = require("path");
const dirPath = path.join(__dirname); const dirPath = path.join(__dirname);
require("@babel/register")({ if (process.env.NODE_ENV !== "production") {
require("@babel/register")({
presets: [ presets: [
[require.resolve("@babel/preset-env")], [require.resolve("@babel/preset-env")],
[ [
@ -25,6 +26,7 @@ require("@babel/register")({
], ],
], ],
ignore: ["node_modules", ".next"], ignore: ["node_modules", ".next"],
}); });
}
module.exports = require("./server.js"); module.exports = require("./server.js");

View File

@ -1,10 +1,10 @@
if (process.env.NODE_ENV !== "production") { if (process.env.NODE_ENV !== "production") {
require("dotenv").config(); require("dotenv").config();
}
require("@babel/register")({ require("@babel/register")({
presets: ["@babel/preset-env"], presets: ["@babel/preset-env"],
ignore: ["node_modules", ".next"], ignore: ["node_modules", ".next"],
}); });
}
module.exports = require("./" + process.argv[2] + ".js"); module.exports = require("./" + process.argv[2] + ".js");