Vue
Knapsack for Vue works by scanning your specified Vue code locations and automatically discovering reusable components, making them instantly available in your design system.
Why This Approach:
- ⚡ Zero Manual Work - Knapsack finds and configures your components automatically
- 🔄 Always Current - Your documentation stays in sync with code changes
- 🎯 Intelligent - Understands different export patterns and component structures
- 🚀 Scale Effortlessly - Handle hundreds of components without individual setup
Requirements
- Vue 2 or Vue 3 - Both versions are supported
- Webpack configuration - You’re responsible for setting up vue-loader and VueLoaderPlugin when using
skipWebpackAlter: true
Install
Configure
Minimal Setup The simplest configuration requires just specifying where your Vue components are located:
Full Configuration Example Here’s a comprehensive example showing all available options:
Code Sources
The codeSrcs array tells Knapsack where to find your Vue components and how to process them. The renderer will scan these paths, find Vue component exports, and make them available in the Knapsack UI for documentation and demos.
Local Components
Paths are relative to knapsack.config.js
External Libraries
Ensure that any external library is included in your package dependencies
Smart Filtering
Use filters to control exactly which components are discovered:
Skip Webpack Alter
When set to true, Knapsack will not modify the Webpack configuration at all. You’ll have complete control over configuring vue-loader (and any related settings) yourself. https://vue-loader.vuejs.org
Webpack Configuration
The Vue renderer uses Webpack under the hood to process your components. When using skipWebpackAlter: true, you’re responsible for setting up your own webpack configuration including vue-loader, VueLoaderPlugin, and other Vue-specific requirements.
Refer to the vue-loader documentation for complete setup instructions.
Common Use Cases
You might need to configure webpack for:
- Path aliases - Create import shortcuts like
@/components/Button - CSS processing - Handle CSS modules, SCSS, styled-components, etc.
- Asset handling - Process images, fonts, and other static files
- TypeScript configuration - Set up TypeScript compilation and path mapping
- Third-party library compatibility - Configure loaders for specific libraries
Common Examples
Here are some common webpack configurations you might need:
Path Aliases
CSS Modules
SCSS Support
Asset Handling
TypeScript Path Mapping