This guide provides step-by-step instructions for setting up your own dual-target Webpack configuration for a React-powered VSCode extension. Whether you're contributing to the Reactive project or starting fresh, these steps will get you up and running quickly.
To follow along with our setup, clone the Reactive project repository:
# Clone the repository
git clone https://github.com/oslabs-beta/reactive.git
# Navigate to the project directory
cd reactive
# Install dependencies
npm install
The package.json
scripts automate the build process for development and production.
# Watch mode for live updates during development
npm run watch
# Build for production (optimized)
npm run build:prod
# Create the .vsix file
npm run package
Use the VSCode Extension Development Host to test your extension:
- Open the project in VS Code.
- Press
F5
or go to Run > Start Debugging. - This will launch a new VS Code window with your extension installed.
When you're ready to publish, package the extension into a .vsix
file:
npm run build:prod
npm run package
The .vsix
file will be created in the project directory and can be uploaded to the VSCode marketplace. TEST IT FIRST! Multiple times. Here's how:
- In VS Code, go to the Extensions view (
Shift+Option+X
on Mac). - Click the hamburger menu at the top-left and select Install from VSIX....
- Locate the
.vsix
file and install it. This will simulate downloading it from the marketplace to ensure the experience is seamless for users.
- Adjust Webpack Configurations: Modify
webpack.config.js
orwebpack.prod.js
to fit your project structure. Ours is just one approach. - Update
tsconfig.json
: Ensure TypeScript settings align with your coding style and target environments. Expect to update this frequently as your code evolves. - Refine
.vscodeignore
: Exclude unnecessary files from your packaged extension. This ensures your.vsix
file remains small and efficient for users to download.
- Backend Configuration: Ensures compatibility with the Node.js runtime for the VSCode extension.
- Frontend Configuration: Prepares the React webview for rendering within the sandboxed VSCode environment.
.vscodeignore
Misconfiguration: Double-check your.vscodeignore
to prevent excluding files critical for runtime.- Testing Overlooked: Always simulate user scenarios by repeatedly testing
.vsix
installation.
For more in-depth guidance, refer to the following documents included in the repository:
- Development Scripts Guide: Detailed explanations of available scripts.
- VS Code Development Guide: Best practices and debugging tips for extension development.
- Contributing Guidelines: Information for contributors and collaborators.
Happy coding with Reactive!