How daniellecuppen/bootstrap5-webpack-boilerplate works
Project type and purpose
• This is a front-end boilerplate template combining Bootstrap 5 and Webpack 5.
• It provides a ready-to-use asset pipeline: SCSS → CSS, ES6+ JS → bundle, font management, environment injection, and a custom responsive-image CLI.
File structure
• Top-level configuration and metadata:
– webpack.config.js, .babelrc, postcss.config.js, images.config.js, .env, package.json
• Source directories:
– src/js (bootstrap.js, main.js) → main application scripts
– src/scss (variables, mixins, components, main.scss) → style definitions
• Assets and fonts:
– fonts/Roboto and fonts/Besley → static font files eot/woff/woff2
– bin/images.js & images.config.js → custom Node.js script for resizing images
• Build outputs:
– dist/ folder containing bundled JS/CSS and generated images
– index.html as entry point referencing compiled assets
Extract insights from the README
• Describes the dev workflow: npm run dev (watch mode), npm run build (production build)
• Uses dotenv-webpack for environment variables loaded at compile-time
• Explains how to add Google Fonts via SCSS mixins and how to configure and run the image resizing command
Main components
A. Developer Workstation
– Source files: src/js, src/scss, fonts/, index.html, images.config.js, .env
– CLI tools: npm scripts (dev, build, images)
B. Build Process (Webpack pipeline)
– Entry: webpack.config.js
– Loaders and plugins:
• babel-loader (transpile ES6+)
• sass-loader + postcss-loader (compile SCSS → CSS, autoprefix/minify)
• file-loader / url-loader (embed or emit fonts and images)
• dotenv-webpack (inject env variables into JS)
– Output: hashed/minified JS, CSS files, copied or optimized assets in dist/
C. Image Resizing Script (bin/images.js)
– Reads images.config.js
– Uses Sharp or similar library to generate multiple image sizes
– Writes to dist/images/*
D. Deployment / Browser
– index.html loads compiled CSS/JS
– User’s browser renders assets
Relationships and data flow
• Developer triggers npm run dev or build
• Webpack reads webpack.config.js →
– Processes JS and SCSS through loaders/plugins → bundles into /dist/js and /dist/css
– Copies or optimizes fonts and static assets from /fonts to /dist/fonts
– Injects .env variables into the bundle
• If npm run images is invoked → bin/images.js reads images.config.js → generates resized images under /dist/images
• The final /dist folder is served to the browser
Architectural patterns and principles
• Modular pipeline: each file type (JS, SCSS, fonts, images) handled by a specific loader or script
• Separation of concerns: build configuration (webpack.config.js), environment management (.env + dotenv plugin), asset generation (images.config.js + Node script)