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,30 +1,32 @@
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") {
presets: [ require("@babel/register")({
[require.resolve("@babel/preset-env")], presets: [
[ [require.resolve("@babel/preset-env")],
require.resolve("next/babel"), [
{ require.resolve("next/babel"),
"preset-env": {}, {
"transform-runtime": {}, "preset-env": {},
"styled-jsx": {}, "transform-runtime": {},
"class-properties": {}, "styled-jsx": {},
}, "class-properties": {},
],
],
plugins: [
[
require.resolve("babel-plugin-module-resolver"),
{
alias: {
"~": dirPath,
}, },
}, ],
], ],
], plugins: [
ignore: ["node_modules", ".next"], [
}); require.resolve("babel-plugin-module-resolver"),
{
alias: {
"~": dirPath,
},
},
],
],
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")({
presets: ["@babel/preset-env"],
ignore: ["node_modules", ".next"],
});
} }
require("@babel/register")({
presets: ["@babel/preset-env"],
ignore: ["node_modules", ".next"],
});
module.exports = require("./" + process.argv[2] + ".js"); module.exports = require("./" + process.argv[2] + ".js");