π POSIX + π¦ Webpack, an unlikely story!
Zero-config Webpack wrapper for React applications with opinionated defaults and modern toolchain integration.
- Zero Configuration - Works out of the box with sensible defaults
- Convention over Configuration - Smart project structure detection
- Modern Toolchain - SWC, TailwindCSS, PostCSS, CSS Modules, MDX support
- Flexible Configuration - Project configs override defaults when present
- Development Experience - Hot reload, React Refresh, bundle analysis
- Production Ready - Optimized builds with code splitting and caching
npm install --save-dev @asd14/vblocks
This package requires and assumes you already installed:
{
"peerDependencies": {
"react": "^18 || ^19",
"react-dom": "^18 || ^19"
}
}
# Start development server
npx vblocks serve
# Build for production
npx vblocks build
# View webpack configuration
npx vblocks eject webpack
VBlocks expects a standard React project structure:
your-project/
βββ src/
β βββ index.tsx # Application entry point
β βββ index.html # HTML template
β βββ index.css # Global styles (optional)
β βββ public/
β βββ favicon.svg # Favicon (optional)
β βββ robots.txt # Robots file (optional)
βββ .env # Environment variables (optional)
βββ dist/ # Build output
VBlocks is a POSIX shell script wrapper around Webpack that:
- Detects configuration files - Uses project configs when available, falls back to defaults
- Sets environment variables - Passes config paths to Webpack via env vars
- Proxies commands -
build
andserve
are passed directly towebpack
with custom parameters - Provides configuration inspection -
eject
outputs configuration content for review
Project files take precedence over defaults:
- Project configs (in your project root) - highest priority
- Default configs (from vblocks package) - fallback
webpack.config.js
- Webpack configurationpostcss.config.js
- PostCSS configurationtailwind.config.js
- TailwindCSS configuration.swcrc
- SWC configuration
Create any of these files in your project root to customize behavior:
// tailwind.config.js - customize TailwindCSS
export default {
content: ["./src/**/*.{ts,tsx}"],
theme: {
extend: {
colors: {
primary: "#your-color"
}
}
}
}
Proxies to:
npx webpack serve --config $VB_WEBPACK_CONFIG --env entryDir=$PROJECT_DIR ...
Starts development server with:
- Hot Module Replacement
- Automatic browser opening
- Bundle analyzer (non-opening)
- Error overlay
- History API fallback for SPAs
Proxies to:
npx webpack build --config $VB_WEBPACK_CONFIG --env entryDir=$PROJECT_DIR ...
Creates production build with:
- Minified assets
- Content hashing
- Optimized chunks
- Performance hints
Special command - Outputs the webpack configuration to stdout for inspection:
npx vblocks eject webpack > webpack.config.js
- Global CSS -
import './styles.css'
- Local CSS Modules -
import styles from './component.module.css'
- camelCase exports -
.my-class
becomesstyles.myClass
- Development-friendly naming - includes class names in dev builds
- Images - Automatic optimization, inlined if < 10KB
- Fonts - Copied to
fonts/
directory - Favicon & Robots - Automatically included in build
VBlocks automatically loads .env
files in your project root:
# .env
REACT_APP_API_URL=https://api.example.com
Access in your code:
const apiUrl = process.env.REACT_APP_API_URL
Built-in alias for cleaner imports:
// Instead of: import { Component } from '../../../components'
import { Component } from "@self/components"
BSD 3-Clause