How to use the browserslist.findConfig function in browserslist

To help you get started, we’ve selected a few browserslist 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 mapbox / underreact / lib / default-underreact.config.js View on Github external
module.exports = (cliOpts = {}) => {
  const rootDirectory = path.dirname(cliOpts.configPath);
  const underreactRoot = path.resolve(__dirname, '..');

  return {
    // Avoid overriding browserslist query, if the user is setting it
    // outside of underreact.config.js,
    browserslist: browserslist.findConfig(rootDirectory)
      ? undefined
      : defaultBrowserslistQuery,
    compileNodeModules: true,
    devServerHistoryFallback: false,
    environmentVariables: {},
    hot: true,
    htmlSource: require(path.join(underreactRoot, 'lib', 'default-html.js')),
    jsEntry: path.join(rootDirectory, 'src', 'index.js'),
    liveReload: true,
    modernBrowserTest: `'fetch' in window && 'assign' in Object`,
    outputDirectory: path.join(rootDirectory, '_site'),
    polyfill: path.resolve(underreactRoot, 'polyfill', 'index.js'),
    host: cliOpts.host || '127.0.0.1',
    port: cliOpts.port || 8080,
    postcssPlugins: [],
    publicAssetsPath: 'underreact-assets',
github faucet-pipeline / faucet-pipeline-core / lib / util / browserslist.js View on Github external
exports.determineBrowserslist = function determineBrowserslist(rootDir) {
	let browsers = browserslist.findConfig(rootDir);
	// limit Browserslist support to default group for now
	return browsers && browsers.defaults;
};
github preactjs / preact-cli / packages / cli / lib / lib / webpack / webpack-base-config.js View on Github external
module.exports = function(env) {
	const { cwd, isProd, isWatch, src, source } = env;

	// Apply base-level `env` values
	env.dest = resolve(cwd, env.dest || 'build');
	env.manifest = readJson(source('manifest.json')) || {};
	env.pkg = readJson(resolve(cwd, 'package.json')) || {};

	let babelrc = readJson(resolve(cwd, 'old')) || {};

	// use browserslist config environment, config default, or default browsers
	// default browsers are > 0.25% global market share or Internet Explorer >= 9
	const browserslistDefaults = ['> 0.25%', 'IE >= 9'];
	const browserlistConfig = Object(browserslist.findConfig(cwd));
	const browsers =
		(isProd ? browserlistConfig.production : browserlistConfig.development) ||
		browserlistConfig.defaults ||
		browserslistDefaults;

	let userNodeModules = findAllNodeModules(cwd);
	let cliNodeModules = findAllNodeModules(__dirname);
	let nodeModules = [...new Set([...userNodeModules, ...cliNodeModules])];

	let compat = 'preact-compat';
	try {
		requireRelative.resolve('preact/compat', cwd);
		compat = 'preact/compat';
	} catch (e) {}

	let babelConfig = Object.assign(
github trustworktech / create-react-ssr-app / packages / react-ssr-dev-utils / browsersHelper.js View on Github external
function checkBrowsers(dir, isInteractive, retry = true) {
  const current = browserslist.findConfig(dir);
  if (current != null) {
    return Promise.resolve(current);
  }

  if (!retry) {
    return Promise.reject(
      new Error(
        chalk.red(
          'To use react-ssr-scripts you must specify targeted browsers.'
        ) +
          os.EOL +
          `Please add a ${chalk.underline(
            'browserslist'
          )} key to your ${chalk.bold('package.json')}.`
      )
    );
github faucet-pipeline / faucet-pipeline-core / lib / index.js View on Github external
module.exports = (referenceDir, config,
		{ watch, fingerprint, sourcemaps, compact, serve, liveserve }) => {
	let assetManager = new AssetManager(referenceDir, {
		manifestConfig: config.manifest,
		fingerprint,
		exitOnError: !watch
	});
	let browsers = browserslist.findConfig(referenceDir) || {};

	let plugins = Object.assign({}, DEFAULTS.plugins, config.plugins);
	let buckets = {
		static: [],
		scripts: [],
		styles: [],
		markup: []
	};
	Object.keys(plugins).forEach(type => {
		let pluginConfig = config[type];
		if(!pluginConfig) {
			return;
		}

		let { bucket, plugin } = plugins[type];
		if(!plugin.call) {