How to use the umi-core/lib/getUserConfig.default function in umi-core

To help you get started, we’ve selected a few umi-core 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 umijs / umi / packages / umi-serve / bin / umi-serve.js View on Github external
const compression = require('compression');
const { winPath } = require('umi-utils');
const getUserConfig = require('umi-core/lib/getUserConfig');
const getPaths = require('umi-core/lib/getPaths');
const boxen = require('boxen');
const clipboardy = require('clipboardy');
const os = require('os');
const port = process.env.PORT || 8001;
const cwd = process.cwd();

let paths;

// 获取 config 之前先注册一遍
registerBabel();

const config = getUserConfig.default({ cwd });
paths = getPaths.default({ cwd, config });

const app = express();

// Gzip support
app.use(
  compression({
    filter: (req, res) => {
      if (req.headers['x-no-compression']) {
        // don't compress responses with this request header
        return false;
      }
      // fallback to standard filter function
      return compression.filter(req, res);
    },
  }),