Skip to content

Commit 339f94d

Browse files
Define .browserslistrc as the single source of truth and embed it in npm package (#42195)
1 parent cee9d6d commit 339f94d

6 files changed

Lines changed: 18 additions & 5 deletions

File tree

.bundlewatch.config.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
},
1515
{
1616
"path": "./dist/css/bootstrap-reboot.min.css",
17-
"maxSize": "5.0 kB"
17+
"maxSize": "5.25 kB"
1818
},
1919
{
2020
"path": "./dist/css/bootstrap-utilities.css",

build/css-minify.mjs

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,17 @@ const distDir = path.join(process.cwd(), 'dist/css')
1717
const cssFiles = fs.readdirSync(distDir)
1818
.filter(file => file.endsWith('.css') && !file.endsWith('.min.css'))
1919

20-
// Target browsers (matching Bootstrap's browser support)
21-
const targets = browserslistToTargets(['> 0.5%', 'last 2 versions', 'Firefox ESR', 'not dead'])
20+
// Target browsers (read from .browserslistrc when available)
21+
let targets
22+
try {
23+
// eslint-disable-next-line import/no-extraneous-dependencies
24+
const { default: browserslist } = await import('browserslist')
25+
const browsers = browserslist()
26+
console.log('Target browsers from .browserslistrc:', browsers)
27+
targets = browserslistToTargets(browsers)
28+
} catch {
29+
console.error('Could not load browserslist')
30+
}
2231

2332
for (const file of cssFiles) {
2433
const inputPath = path.join(distDir, file)

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -199,7 +199,8 @@
199199
"js/{src,dist}/**/*.{js,map}",
200200
"js/index.js",
201201
"scss/**/*.scss",
202-
"!scss/tests/**"
202+
"!scss/tests/**",
203+
".browserslistrc"
203204
],
204205
"overrides": {
205206
"volar-service-emmet": "0.0.63"

site/src/content/docs/customize/optimize.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ const dialog = new Dialog(document.getElementById('myDialog'))
4848

4949
## Autoprefixer .browserslistrc
5050

51-
Bootstrap depends on Autoprefixer to automatically add browser prefixes to certain CSS properties. Prefixes are dictated by our `.browserslistrc` file, found in the root of the Bootstrap repo. Customizing this list of browsers and recompiling the Sass will automatically remove some CSS from your compiled CSS, if there are vendor prefixes unique to that browser or version.
51+
Bootstrap depends on Autoprefixer to automatically add browser prefixes to certain CSS properties. Prefixes are dictated by our `.browserslistrc` file, found in the root of the Bootstrap repo and at the root of the npm package (`node_modules/bootstrap/.browserslistrc`). Customizing this list of browsers and recompiling the Sass will automatically remove some CSS from your compiled CSS, if there are vendor prefixes unique to that browser or version.
5252

5353
## Unused CSS
5454

site/src/content/docs/getting-started/approach.mdx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,8 @@ You can find our supported range of browsers and their versions [in our `.browse
139139

140140
<Code lang="plaintext" filePath=".browserslistrc" />
141141

142+
If you installed Bootstrap via npm, you can also find this file locally at `node_modules/bootstrap/.browserslistrc`.
143+
142144
We use [Autoprefixer](https://github.com/postcss/autoprefixer) to handle intended browser support via CSS prefixes, which uses [Browserslist](https://github.com/browserslist/browserslist) to manage these browser versions. Consult their documentation for how to integrate these tools into your projects.
143145

144146
## Guiding principles

site/src/content/docs/getting-started/install.mdx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ Bootstrap’s `package.json` contains some additional metadata under the followi
4141

4242
- `sass` - path to Bootstrap’s main [Sass](https://sass-lang.com/) source file
4343
- `style` - path to Bootstrap’s non-minified CSS that’s been compiled using the default settings (no customization)
44+
- `.browserslistrc` - shipped at the package root for Browserslist/Autoprefixer browser targets
4445

4546
### Using Yarn
4647

0 commit comments

Comments
 (0)