read config for webpack dev server
332455
function readWebpackConfig( server ) {

  const devConfig = server.webpackConfig && server.webpackConfig.dev;
  const configFile = paths.resolveApp( devConfig ) || appWebpackDevConfig;

  try {

    assert(
      existsSync( configFile ),
      `File ${devConfig || WEBPACK_DEV_CONFIG} is not exsit.`
    );

    const wpConfig = getConfig( configFile );

    // plugins: function
    if ( is.Function( wpConfig.plugins )) {
      wpConfig.plugins = wpConfig.plugins( wpConfig );
    }

    // plugins: not array
    if ( !is.Array( wpConfig.plugins )) {
      wpConfig.plugins = [wpConfig.plugins];
    }

    // plugins: array in array
    wpConfig.plugins = flatten( wpConfig.plugins.map(( plugin ) => {
      return is.Function( plugin ) ? plugin( wpConfig ) : plugin;
    }));

    server.webpackDevConfig = wpConfig;
    watchFiles.push( configFile );

    return Right( server );
  } catch ( e ) {
    print(
      chalk.red( `Failed to read ${devConfig || WEBPACK_DEV_CONFIG}.` ),
      e.message
    );
    print();
    return Left( null );
  }
}
269056
function loadConfigFile(configInfo) {
    const { filePath } = configInfo;
    let config;

    switch (path.extname(filePath)) {
        case ".js":
            config = loadJSConfigFile(filePath);
            if (configInfo.configName) {
                config = config.configs[configInfo.configName];
                if (!config) {
                    throw configMissingError(configInfo.configFullName);
                }
            }
            break;

        case ".json":
            if (path.basename(filePath) === "package.json") {
                config = loadPackageJSONConfigFile(filePath);
                if (config === null) {
                    return null;
                }
            } else {
                config = loadJSONConfigFile(filePath);
            }
            break;

        case ".yaml":
        case ".yml":
            config = loadYAMLConfigFile(filePath);
            break;

        default:
            config = loadLegacyConfigFile(filePath);
    }

    return ConfigOps.merge(ConfigOps.createEmptyConfig(), config);
}
485401
function makeWebpackExternalsConfig(moduleNames) {
  return moduleNames.reduce((externals, moduleName) => Object.assign(externals, {
    [moduleName]: `commonjs ${moduleName}`,
  }), {});
}
489051
async function setupServer() {
  return new Promise(async (resolve, reject) => {
    config = config || (await getConfig());
    config.components.individual = [];
    config.prod = true;
    config.enableCache = true;
    config.mode = 'server';
    config.env = 'pwa';
    config.sourceMaps = false;
    config.copy = [];
    config.webpackDevServer = false;
    config.buildDir = path.join(config.wwwDir, 'build-ssr');
    config.dataDir = path.join(config.wwwDir, 'build-ssr', 'data');

    app.use(express.static(path.relative(process.cwd(), config.wwwDir)));

    // generate a fresh webpack build + pass along asset data to dynamic HTML template rendered
    server = await app.listen(port);

    app.get('/ssr', function(req, res) {
      res.send(template(html || '', port, webpackStatsGenerated || []));
    });

    // handle cleaning up + shutting down the server instance
    process.on('SIGTERM', shutDownSSRServer);
    process.on('SIGINT', shutDownSSRServer);

    server.on('connection', connection => {
      connections.push(connection);
      connection.on(
        'close',
        // eslint-disable-next-line no-return-assign
        () => (connections = connections.filter(curr => curr !== connection)),
      );
    });

    resolve();
  });
}
1210727
function getWebpackConfig(skyPagesConfig, argv) {
  const common = require('./common.webpack.config');

  return webpackMerge(common.getWebpackConfig(skyPagesConfig, argv), {
    devtool: 'source-map',
    module: {
      rules: [
        {
          test: /\.ts$/,
          use: [
            {
              loader: 'awesome-typescript-loader',
              options: {
                // Ignore the "Cannot find module" error that occurs when referencing
                // an aliased file.  Webpack will still throw an error when a module
                // cannot be resolved via a file path or alias.
                ignoreDiagnostics: [2307],
                transpileOnly: true
              }
            },
            {
              loader: 'angular2-template-loader'
            }
          ]
        }
      ]
    },
    plugins: [
      SaveMetadata,
      new webpack.optimize.UglifyJsPlugin({
        beautify: false,
        comments: false,
        mangle: { screw_ie8: true, keep_fnames: true },
        sourceMap: true
      })
    ]
  });
}
51485
async function getWebpackSizes() {
  await fse.mkdirp(path.join(__dirname, 'build'));

  const configPath = path.join(__dirname, 'webpack.config.js');
  const statsPath = path.join(__dirname, 'build', 'stats.json');
  await exec(`webpack --config ${configPath} --json > ${statsPath}`);

  const stats = await fse.readJSON(statsPath);
  const assets = new Map(stats.assets.map(asset => [asset.name, asset]));

  return Object.entries(stats.assetsByChunkName).map(([chunkName, assetName]) => {
    const parsedSize = assets.get(assetName).size;
    const gzipSize = assets.get(`${assetName}.gz`).size;
    return [chunkName, { parsed: parsedSize, gzip: gzipSize }];
  });
}
778489
function loadConfig() {
  underload('whitelist', 'whitelist.file');

  if (!program['bower'] && config.has('packages.type') && config.get('packages.type') == 'bower') {
    program['bower'] = true;
  }

  if (!program['noNode'] && config.has('packages.withNode') && config.get('packages.withNode') == false) {
    program['noNode'] = true;
  }

  underload('package', 'packages.file');

  underload('level', 'logging.level');
  underload('quiet', 'logging.quiet');
  underload('verbose', 'logging.verbose');

  underload('scheme', 'server.scheme');
  underload('host', 'server.host');
  underload('port', 'server.port');

  underload('cacheDir', 'cache.path');

  underload('cacheTimeout', 'cache.timeout')

  underload('username', 'auth.user');
  underload('token', 'auth.token');
}
808633
def read_config_file(path):
    """"""
    try:
        with open(path, 'r') as f:
            return json.load(f, object_pairs_hook=OrderedDict)
    except IOError as ex:
        if ex != errno.ENOENT:
            raise
    return {}
443615
def _read_configfile(self):
        """"""
        rc = self.config_filename
        if not os.path.isabs(rc):
            rc = os.path.join(os.path.expanduser('~'), self.config_filename)
        # If there is a setup.cfg in the package, parse it
        files = [f for f in [rc, 'setup.cfg'] if os.path.exists(f)]
        if not files:
            self.config = None
            return
        self.config = ConfigParser()
        self.config.read(files)
        if (not self.is_old_pypi_config() and
                not self.is_new_pypi_config()):
            # Safety valve
            self.config = None
1264544
function getConfig(api) {
  const conf = api.resolveChainableWebpackConfig()

  // because we are dealing with hot replacement in vsg
  // remove duplicate hot module reload plugin
  conf.plugins.delete('hmr')

  // remove the double compiled successfully message
  conf.plugins.delete('friendly-errors')
  return api.resolveWebpackConfig(conf)
}
1200620
function createConfig(pkg, moduleFormat, productive) {
  return {
    input: `src/modules/${pkg}/main/index.ts`, 

    output: {
      file: productive
        ? `dist/js-surface.${pkg}.${moduleFormat}.production.js`
        : `dist/js-surface.${pkg}.${moduleFormat}.development.js`,

      format: moduleFormat,
      
      name: {
        core: 'jsSurface',
        all: 'jsSurface',
        html: 'jsSurface.Html',
        svg: 'jsSurface.Svg'
      }[pkg] || `jsSurface.${pkg}`,
     
      sourcemap: productive ? false : 'inline',

      globals: {
        'js-surface': 'jsSurface',
        'react': 'React',
        'react-dom': 'ReactDOM',
        'dyo': 'Dyo',
        'js-spec': 'jsSpec'
      }
    },

    external: ['js-surface', 'react', 'react-dom', 'dyo'].concat(productive ? 'js-spec' : []), 

    plugins: [
      resolve({
        jsnext: true,
        main: true,
        browser: true,
      }),
      commonjs(),
      // TODO: Configure "tslint.json" properly and fix all errors
      //tslint({
      //  throwOnError: true
      //}),
      replace({
        exclude: 'node_modules/**',
        delimiters: ['', ''],

        values:
          pkg === 'all' ? {
            'process.env.NODE_ENV': productive ? "'production'" : "'development'",
          } : {
            'process.env.NODE_ENV': productive ? "'production'" : "'development'",
            "'../core/main/index'": "'js-surface'",
            "'../../core/main/index'": "'js-surface'",
            "'../../../core/main/index'": "'js-surface'",
            "'../../../../core/main/index'": "'js-surface'",
            "'../../../../../core/main/index'": "'js-surface'",
          }
      }),
      typescript({
        exclude: 'node_modules/**',
      }),
      productive && (moduleFormat === 'esm' ? terser() : uglify()),
      productive && gzip()
    ],
  }
}
1031536
function _load() {
  if (!existsSync(exports.configFile)) {
    _initFile();
  }

  try {
    return JSON.parse(fs.readFileSync(exports.configFile, 'utf8'));
  }
  catch (e) {
    console.error('JSON parse error');
    console.error('See and edit', exports.configFile);
    console.error('or exec `confy clean`');
    process.exit();
  }
}
200856
function _loadWebpackConfig(configFileName) {
  const customWebpackConfigPath = path.join(process.cwd(), configFileName);

  let webpackConfig = null;

  try {
    webpackConfig = require(customWebpackConfigPath);
  } catch(err) {}

  if (!webpackConfig) {
    webpackConfig = require('../config/webpack/webpack.config.js');
  } else {
    console.log('R> loaded custom webpack config: ', customWebpackConfigPath)
  }

  return webpackConfig;
}
646737
function getWebpackConfig(skyPagesConfig, argv) {
  const common = require('./common.webpack.config');

  // Webpackmege will attempt to merge each entries array, so we need to delete it
  let commonConfig = common.getWebpackConfig(skyPagesConfig, argv);
  commonConfig.entry = null;

  // Since the preloader is executed against the file system during an AoT build,
  // we need to remove it from the webpack config, otherwise it will get executed twice.
  commonConfig.module.rules = commonConfig.module.rules
    .filter((rule) => {
      const isPreloader = /(\/|\\)sky-processor(\/|\\)/.test(rule.loader);
      return (!isPreloader);
    });

  return webpackMerge(commonConfig, {
    entry: {
      polyfills: [skyPagesConfigUtil.spaPathTempSrc('polyfills.ts')],
      vendor: [skyPagesConfigUtil.spaPathTempSrc('vendor.ts')],
      skyux: [skyPagesConfigUtil.spaPathTempSrc('skyux.ts')],
      app: [skyPagesConfigUtil.spaPathTempSrc('main-internal.aot.ts')]
    },
    
    // Disable sourcemaps for production:
    // https://webpack.js.org/configuration/devtool/#production
    devtool: undefined,
    
    module: {
      rules: [
        {
          test: /\.ts$/,
          loader: '@ngtools/webpack'
        }
      ]
    },
    plugins: [
      new ngtools.AotPlugin({
        tsConfigPath: skyPagesConfigUtil.spaPathTempSrc('tsconfig.json'),
        entryModule: skyPagesConfigUtil.spaPathTempSrc('app', 'app.module') + '#AppModule',
        // Type checking handled by Builder's ts-linter utility.
        typeChecking: false
      }),
      SaveMetadata,
      new webpack.optimize.UglifyJsPlugin({
        beautify: false,
        comments: false,
        compress: { warnings: false },
        mangle: { screw_ie8: true, keep_fnames: true }
      })
    ]
  });
}
641082
function getConfig(api) {
	const conf = api.resolveChainableWebpackConfig()

	// because we are dealing with hot replacement in vsg
	// remove duplicate hot module reload plugin
	conf.plugins.delete('hmr')

	const eslintRule = conf.module.rule('eslint')
	if (eslintRule) {
		const path = require('path')
		const vsgPath = path.resolve(path.dirname(require.resolve('vue-styleguidist')), '../')
		eslintRule.exclude.add(vsgPath)
	}

	// remove the double compiled successfully message
	conf.plugins.delete('friendly-errors')
	return api.resolveWebpackConfig(conf)
}
301972
def _read_config(self):
        """"""
        config = configparser.ConfigParser()
        config.read(self.path)
        if config.has_section('distutils'):
            server_names = config.get('distutils', 'index-servers')
            servers = [name.strip() for name in server_names.split('\n')]
            servers = [server for server in servers if server]

            for server in servers:
                repo_config = RepositoryConfig(server)
                repo_config.fill(config, server)
                self.repositories.append(repo_config)

        repo_config = RepositoryConfig('default')
        repo_config.fill(config, 'server-login')
879746
async function watch() {
  let webpackConfig = config

  if (get(manifest, 'skypager.webpack.build')) {
    let configToMerge = require(path.resolve(
      path.dirname(paths.appPackageJson),
      get(manifest, 'skypager.webpack.build')
    ))

    if (typeof configToMerge === 'function') {
      configToMerge = await Promise.resolve(configToMerge(argv.env || 'production', argv, config))
    }

    if (!isArray(configToMerge)) {
      // we won't try and merge webpack config if it is an array
      webpackConfig = configMerge(webpackConfig, configToMerge)
    }
  }

  const compiler = webpack(webpackConfig)

  compiler.watch({ aggregateTimeout: 1000 }, (err, stats) => {
    if (err) {
      console.error(err)
      return
    }
    const messages = formatWebpackMessages(stats.toJson({}, true))

    if (messages.errors.length) {
      // Only keep the first error. Others are often indicative
      // of the same problem, but confuse the reader with noise.
      if (messages.errors.length > 1) {
        messages.errors.length = 1
      }

      throw new Error(messages.errors.join('\n\n'))
    }
  })
}