A Webpack 4 plugin that externalizes node_modules in development and replaces them with CDN scripts in production, reducing build times and improving page load performance. Version 3.3.1 is the latest stable release, with no active development since 2019. It integrates with html-webpack-plugin (peer dep >=3) to inject script/link tags for external libraries like Vue or React. Key differentiators: automatic CDN URL generation via unpkg or custom paths, supports multiple pages via cdnModule option, and works with custom HTML templates. Only supports Webpack 4; for Webpack <4 use v1.x. Requires Node >=6.9.
npm install webpack-cdn-pluginVerified import paths — ran on the pinned version, not inferred.
Configures Webpack CDN Plugin with Vue and vue-router for development serving via node_modules, production via unpkg CDN.
Use an alternative like `webpack-cdn-plugin` v2.x? Actually v3 only works with Webpack 4. Consider migrating to Webpack 5 compatible plugins (e.g., dynamic CDN via html-webpack-plugin).
Migrate to modern CDN injection solutions like `html-webpack-plugin` with custom `ejs` templates or `webpack-subresource-integrity` plus external configuration.
Ensure all CDN modules are listed in package.json and installed locally. For non-npm packages, use the 'url' option instead of 'name'.
Configure your dev server (e.g., webpack-dev-server) to serve the node_modules folder at the same publicPath, or set prod to true with a CDN URL.
Set cdnModule to a key defined in the modules object configuration for the WebpackCdnPlugin.
Run `npm install webpack-cdn-plugin --save-dev` or `yarn add webpack-cdn-plugin --dev`.
Use `const WebpackCdnPlugin = require('webpack-cdn-plugin');` instead of `import`.Change `module: [...]` to `modules: [...]` in WebpackCdnPlugin constructor options.
Ensure html-webpack-plugin is installed (`npm install html-webpack-plugin --save-dev`) and add it to plugins array before WebpackCdnPlugin.