How to use the umi-core/lib/getUserConfig.getConfigFile 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-build-dev / src / plugins / commands / generate / generators / page / index.js View on Github external
join(paths.absPagesPath, `${path}.${jsxExt}`),
        context,
      );
      this.fs.copyTpl(
        this.templatePath('page.css.tpl'),
        join(paths.absPagesPath, `${path}.${cssExt}`),
        context,
      );

      if (config.routes) {
        writeNewRoute(
          {
            path: `/${path === 'index' ? '' : path}`,
            component: `./${path}`,
          },
          getConfigFile(cwd),
          paths.absSrcPath,
        );
        // log.warn(
        //   `You should config the routes in config.routes manunally since ${chalk.red(
        //     'config.routes',
        //   )} exists`,
        // );
        console.log();
      }
    }
  };
github umijs / umi / packages / umi-build-dev / src / UserConfig.js View on Github external
getConfig(opts = {}) {
    const { paths, cwd } = this.service;
    const { force, setConfig } = opts;
    const defaultConfig = this.service.applyPlugins('modifyDefaultConfig', {
      initialValue: {},
    });

    const file = getConfigFile(cwd);
    this.file = file;
    if (!file) {
      return defaultConfig;
    }

    // 强制读取,不走 require 缓存
    if (force) {
      cleanConfigRequireCache(cwd);
    }

    let config = null;
    const relativeFile = file.replace(`${paths.cwd}/`, '');
    this.relativeFile = relativeFile;

    const onError = (e, file) => {
      const msg = `配置文件 "${file.replace(`${paths.cwd}/`, '')}" 解析出错,请检查语法。