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 dirPath = path.join(__dirname);
require("@babel/register")({
presets: [
[require.resolve("@babel/preset-env")],
[
require.resolve("next/babel"),
{
"preset-env": {},
"transform-runtime": {},
"styled-jsx": {},
"class-properties": {},
},
],
],
plugins: [
[
require.resolve("babel-plugin-module-resolver"),
{
alias: {
"~": dirPath,
if (process.env.NODE_ENV !== "production") {
require("@babel/register")({
presets: [
[require.resolve("@babel/preset-env")],
[
require.resolve("next/babel"),
{
"preset-env": {},
"transform-runtime": {},
"styled-jsx": {},
"class-properties": {},
},
},
],
],
],
ignore: ["node_modules", ".next"],
});
plugins: [
[
require.resolve("babel-plugin-module-resolver"),
{
alias: {
"~": dirPath,
},
},
],
],
ignore: ["node_modules", ".next"],
});
}
module.exports = require("./server.js");

View File

@ -1,10 +1,10 @@
if (process.env.NODE_ENV !== "production") {
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");