npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

bootstrap-compiler

v1.1.1

Published

Compile a custom Bootstrap (V5) build.

Downloads

22

Readme

GitHub Coverage

A library to compile Bootstrap V5 SCSS that can be used in a browser.

Overview

bootstrap-compiler is a Javascript library that builds a CSS stylesheet from the Bootstrap sources. It's primarily intended to customize Bootstrap in a browser-based application.

Getting Started

Here is an example usage that builds bootstrap with default options:

const bootstrapCompiler = require('bootstrap-compiler/dist/bootstrap-compiler');

let result = bootstrapCompiler.compile(bootstrapCompiler.SOURCE_CACHE['bootstrap']);
let css = result.css.toString();

The css variable contains the generated CSS.

Javascript API

The bootstrap-compiler library uses a version of Dart SASS built for the browser to generate a CSS file. Since the library file contains a SASS compiler (2M uncompressed) and all Bootstrap source files (44K), the resulting file size is big, 1.5MB minified, so plan accordingly.

The API consists of a single function compile() and two variables SOURCE_CACHE and BOOTSTRAP_VERSION.

compile()

let result = bootstrapCompler.compile(scss, options)
  • scss - The custom SCSS file to build. The intended input is one of the top level Bootstrap source SCSS files e.g. this but any SCSS file will work. Any imports statements will be automatically replaced with the corresponding Bootstrap source.
  • options - The options object passed directly to Dart-SASS. This object is passed as-is except for data is replaced with the above scss value and file is ignored.

The compile function returns a Dart SASS result object.

SOURCE_CACHE

The SOURCE_CACHE constant is a mapping of the Bootstrap source files keyed by the base file name e.g. the contents of _variables.scss are found via SOURCE_CACHE['variables']. Subdirectories of source files are concatenated under the directory name as well as stored by individual file names. For example, SOURCE_CACHE['forms'] contains the concatenation of all files in the forms subdirectory and the individual file contents for forms/_form-text.scss is found via SOURCE_CACHE['forms/form-text'].

BOOTSTRAP_VERSION

BOOTSTRAP_VERSION contains the version number of the contained Bootstrap source code, currently 5.0.0-alpha3.

CLI

This package contains a command-line tool bootstrap-compiler which may be used to test the compiler against a specified source file. To build the full BS5 source from the command line do:

bootstrap-compiler init  # creates style.scss in the current directory
bootstrap-compiler compile  # creates style.css and style.css.map

The primary use for the CLI is validation of the resulting library builds.

Development/Testing

Please submit any issues that you encounter via GitHub

Testing

npm link
npm link bootstrap-compiler
npx webpack
npm run test

The library must be build using webpack before running Jest because several test cases depend on both the source and the compiled result. (This is to validate the webpack build itself).

The tests require Node v12 or higher.