browserslist-load-config
v1.0.0
Published
<p> <a href="https://npmjs.com/package/browserslist-load-config"> <img src="https://img.shields.io/npm/v/browserslist-load-config?style=flat-square&colorA=564341&colorB=EDED91" alt="npm version" /> </a> <img src="https://img.shields.io/badge/Lice
Downloads
2,094
Readme
browserslist-load-config
Introduction
This package is a fork of browserslist.loadConfig with some modifications to make it faster.
Compare to browserslist
, this package has the following improvements and differences:
- 27 times smaller bundle size
- 140 times smaller install size.
- Zero dependencies.
- Written in TypeScript.
- Smaller and faster.
- Does not support env variables.
See bundlephobia - browserslist-load-config vs bundlephobia - browserslist for bundle size comparison.
See packagephobia - browserslist-load-config vs packagephobia - browserslist for install size comparison.
Credits
Thanks Andrey Sitnik for creating the Browserslist which is under MIT License.
Usage
Install:
npm add browserslist-load-config -D
loadConfig
import { loadConfig } from "browserslist-load-config";
// Pass a path to the configuration file
const config = loadConfig({
/**
* Specify the directory where the configuration file is located
*/
path: "./path/to/project/root",
/**
* Specify the environment to load
* @default "production"
*/
env: "production",
});
// Pass a browserslist config directly
const config = loadConfig({
/**
* Specify the directory where the configuration file is located
*/
path: "./path/to/project/root",
/**
* Specify the environment to load
* @default "production"
*/
env: "production",
});
console.log(config);
/**
* [
* // browserslist config
* ]
*/
If both config
and path
are provided, config
will be used.
findConfig
import { findConfig } from "browserslist-load-config";
const config = findConfig("./path/to/project/root");
console.log(config);
/**
* {
* defaults: [
* // default browserslist config
* ],
* development: [
* // development browserslist config
* ],
* production: [
* // production browserslist config
* ],
* }
*/
License
MIT.