Html-webpack-cdn-plugin
cdn in webpack
Useage
Dependencies
cdn-loader You NEAD Install
cdn-loader
andhtml-webpack-plugin
Install
- Run
npm i -D html-webpack-cdn-plugin
in your project folder - Add
var HtmlWebpackCdnPlugin = require('html-webpack-cdn-plugin')
towebpack.config.js
file - Add
new HtmlWebpackCdnPlugin(config)
towebpack.config.js
file (plugins
) - Also you need cdn-loader and html-webpack-plugin
Support
css and js files https://cdnjs.com
Config
Example
// webpack.config.jsvar config =host: "https://cdnjs.cloudflare.com/ajax/libs"cdn:js: "https://cdnjs.cloudflare.com/ajax/libs"css: "https://cdnjs.cloudflare.com/ajax/libs"var webpackConfig =entry: 'index.js'output:path: 'dist'filename: 'index_bundle.js'plugins:config;
// index.jsvar $ =// Now you can use it// cdn-loader// .......more code
Then
app<!-- more code -->