How to use the next-server/dist/server/config.default function in next-server

To help you get started, we’ve selected a few next-server examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github traveloka / soya-next / packages / soya-next-scripts / scripts / build.js View on Github external
process.env.NODE_ENV = process.env.NODE_ENV || "production";

require("soya-next/config/default");

process.on("unhandledRejection", err => {
  throw err;
});

const { appDir } = require("soya-next-server/paths");
const build = require("next/dist/build").default;
const buildSoya = require("./utils/build-soya");
const { PHASE_PRODUCTION_BUILD } = require("next/constants");
const loadConfig = require("next-server/dist/server/config").default;

const defaultConf = require("../next.config");
const userConf = loadConfig(PHASE_PRODUCTION_BUILD, appDir);
const conf = defaultConf(userConf);

build(appDir, conf)
  .then(
    () => buildSoya(),
    err => {
      if (err.code !== "MODULE_NOT_FOUND") {
        throw err;
      }
    }
  )
  .catch(err => {
    // eslint-disable-next-line no-console
    console.error(err.stack);
    process.exit(1);
  });
github traveloka / soya-next / packages / soya-next-server / server.js View on Github external
module.exports = ({ conf = loadDefaultConfig, dev, phase }) => {
  const nextConfig = loadNextConfig(phase, appDir);
  const app = next({ conf: conf(nextConfig), dev }); // eslint-disable-line callback-return
  app
    .prepare()
    .then(() => {
      const server = express();

      config.server.headers &&
        server.use((_, res, next) => {
          Object.keys(config.server.headers).forEach(field => {
            config.server.headers[field] &&
              res.header(field, config.server.headers[field]);
          });
          next();
        });

      const includeSoyaLegacy =
github traveloka / soya-next / packages / soya-next-scripts / scripts / export.js View on Github external
process.env.BABEL_ENV = process.env.BABEL_ENV || "production";
process.env.NODE_ENV = process.env.NODE_ENV || "production";

require("soya-next/config/default");

process.on("unhandledRejection", err => {
  throw err;
});

const { appDir } = require("soya-next-server/paths");
const { join } = require("path");
const nextExport = require("next/dist/export").default;
const { PHASE_EXPORT } = require("next/constants");
const loadConfig = require("next-server/dist/server/config").default;
const defaultConf = require("../next.config");
const userConf = loadConfig(PHASE_EXPORT, appDir);
const conf = defaultConf(userConf);
const printAndExit = (message, code = 1) => {
  if (code === 0) {
    console.log(message);
  } else {
    console.error(message);
  }
  process.exit(code);
};

nextExport(appDir, { silent: false, outdir: join(appDir, "out") }, conf)
  .then(() => {
    printAndExit("Export successful", 0);
  })
  .catch(err => {
    printAndExit(err);