Production build 1.2.2
Publish only what your project uses. Prefer the Production Builder
(velinstyle build --production) over hand-tuned PurgeCSS for VelinStyle assets.
Deutsche Version.
Full guide: Production Builder.
--preset lite remains available without a content scan.
When to use
- Go-live: run
velinstyle productionand linkdist/velin-production/. - Quick marketing CSS without scanning:
velinstyle build --preset lite.
When not
- Do not strip accessibility CSS or focus styles for size wins.
- Do not expect Production to rewrite your HTML (hints only in report / review).
Production command
Scan your project and emit a trimmed VelinStyle production folder:
npx velinstyle build --production --explain
# alias:
npx velinstyle production . -o ./dist/velin-production
Standalone Builds
For CDN users, VelinStyle provides pre-built subsets you can use instead of the full bundle:
| Build | Includes | Size (gzip) |
|---|---|---|
velinstyle.min.css |
Everything | ~38 KB |
dist/themes/*.min.css |
Theme presets (load alongside core CSS) | ~1?2 KB each |
npx velinstyle build |
Custom subset via velinstyle.config.js (CLI) |
varies |
<!-- Smaller bundle: configure layers, then build locally -->
<!-- npx velinstyle init && npx velinstyle build -o dist/my-velin.css --minify -->
<link rel="stylesheet" href="/dist/my-velin.min.css">
<!-- Or pin the full published bundle from npm/CDN -->
<link rel="stylesheet"
href="/dist/velinstyle.min.css">
PurgeCSS Integration
Use PurgeCSS to automatically remove unused CSS classes from your production build. Here's a typical configuration:
// purgecss.config.js
module.exports = {
content: [
'./src/**/*.html',
'./src/**/*.js',
'./src/**/*.jsx',
'./src/**/*.vue',
],
css: ['./node_modules/@birdapi/velinstyle/dist/velinstyle.min.css'],
safelist: [
/^modal/,
/^tooltip/,
/^popover/,
/^offcanvas/,
/^data-velin-theme/,
],
};
Vite & PostCSS
When using Vite with a subset build or PurgeCSS on your HTML, you can shrink CSS further. For additional
optimization, add cssnano to your PostCSS pipeline:
// postcss.config.js
module.exports = {
plugins: [
require('autoprefixer'),
require('cssnano')({
preset: ['default', {
discardComments: { removeAll: true },
}],
}),
],
};
Performance Tips
-
Preload the stylesheet ? Add
<link rel="preload">to start downloading CSS before the parser reaches it:
<link rel="preload" href="/css/velinstyle.min.css" as="style">
<link rel="stylesheet" href="/css/velinstyle.min.css">
- Self-host for production ? Download and serve VelinStyle from your own domain to eliminate third-party DNS lookups and benefit from HTTP/2 multiplexing.
- Enable Brotli/Gzip ? Ensure your server compresses CSS responses. VelinStyle's full build compresses from ~160 KB to ~38 KB with gzip.
-
Use
content-visibility? For long pages, applycontent-visibility: autoon off-screen sections to defer rendering. -
Lazy-load Web Components ? Only import the JS bundle on pages that
use custom elements like
<velin-icon>or<velin-dialog>.