Webpack plugin for building Lightning Web Components (LWC) in any web framework project. Current stable version is 3.1.0, released on a monthly cadence. It allows you to use LWC within any web framework project that uses Webpack. Key differentiators: Provides seamless integration of LWC components with Webpack, supports TypeScript through additional Babel configuration, and allows custom module resolution via lwc.config.json or package.json. Compared to alternatives like raw LWC compiler, it automates component compilation and asset handling within the Webpack bundling process.
npm install lwc-webpack-pluginVerified import paths — ran on the pinned version, not inferred.
Basic setup: require the plugin and add it to webpack plugins array with default module resolution from lwc.config.json.
Install peer deps: npm install --save-dev lwc@^2 @lwc/module-resolver@^2
Remove stylesheetConfig from plugin options.
Ensure you have the correct alias configuration in webpack for @lwc/synthetic-shadow.
Ensure all imported CSS files exist and are correctly referenced.
npm install --save-dev lwc@^2
npm install --save-dev @lwc/module-resolver@^2
Add resolve.alias: { '@lwc/synthetic-shadow': require.resolve('@lwc/synthetic-shadow') } to webpack config.Use const LwcWebpackPlugin = require('lwc-webpack-plugin') or import LwcWebpackPlugin from 'lwc-webpack-plugin'