Loading...
Loading...
Build a Bootstrap 6 starter project using just npm and command-line tools (no bundler). Use when setting up Bootstrap with npm, compiling Bootstrap's Sass to CSS from the command line, or creating an npm-based Bootstrap project.
npx skill4agent add twbs/bootstrap bootstrap-npm<script>mkdir my-project && cd my-project
npm init -y@floating-ui/domvanilla-calendar-pronpm i --save bootstrap@6.0.0-alpha.1 @floating-ui/dom vanilla-calendar-pronpm i --save-dev autoprefixer postcss postcss-cli sassnpm i --save-dev nodemon npm-run-all sirv-cli stylelint stylelint-config-twbs-bootstrapmkdir {css,scss}
touch index.html scss/styles.scss postcss.config.js stylelint.config.mjsmy-project/
├── css/
├── scss/
│ └── styles.scss
├── stylelint.config.mjs
├── index.html
├── package-lock.json
├── package.json
└── postcss.config.jspostcss.config.jsconst autoprefixer = require('autoprefixer')
module.exports = {
plugins: [
autoprefixer
]
}index.htmldist<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Bootstrap w/ npm</title>
<link rel="stylesheet" href="css/styles.css">
</head>
<body>
<div class="container py-4 px-3 mx-auto">
<h1>Hello, Bootstrap and npm!</h1>
<button class="btn-solid theme-primary">Primary button</button>
</div>
<script type="module" src="node_modules/bootstrap/dist/js/bootstrap.bundle.min.js"></script>
</body>
</html>package.json--load-path=node_modulesbootstrap{
"scripts": {
"css-compile": "sass --load-path=node_modules --style expanded --source-map --embed-sources scss:css",
"css-prefix": "postcss --config postcss.config.js --replace \"css/*.css\" \"!css/*.min.css\"",
"build": "npm-run-all --sequential css-compile css-prefix",
"watch": "nodemon --watch scss/ --ext scss --exec \"npm run build\"",
"serve": "sirv --port 8080 --dev .",
"start": "npm-run-all build --parallel watch serve",
"lint": "stylelint \"scss/**/*.scss\""
}
}stylelint.config.mjs/** @type {import('stylelint').Config} */
export default {
extends: 'stylelint-config-twbs-bootstrap'
}npm startscss/styles.scss@use@import// Import all of Bootstrap's CSS
@use "bootstrap/scss/bootstrap";with ()@use "bootstrap/scss/bootstrap" with (
$root-tokens: (
--border-radius: .25rem,
--spacer: 1.5rem,
)
);$root-tokens$*-tokens--border-radius--spacer--bs-npm starthttp://localhost:8080.container.btn-solid.theme-primarycss/styles.cssscss/styles.scssnpm run lintoklch()color-mix()