Skip to content

html-webpack-plugin扩展自定义css js的publicPath 可针对每个js和css设置不同的publicPath用于解决cdn分域名加载的问题

Notifications You must be signed in to change notification settings

AMDvsTMD/html-resource-cdn-plugin

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 

Repository files navigation

Source CDN extension for the HTML Webpack Plugin

Enhances html-webpack-plugin functionality by adding the {cdnSource: [{"type":js,"regstr":".*","publicPath":"//1.cdn.xxx.com/"}]} option.

This is an extension plugin for the webpack plugin html-webpack-plugin. It allows you to define every javascript and css source publicPath.

Installation

You must be running webpack on node 4 or higher

Basic Usage

Require the plugin in your webpack config:

var HtmlResourceCdnPlugin=require("html-resource-cdn-plugin");

Add the plugin to your webpack config as follows:

plugins: [
  new HtmlWebpackPlugin(),
  new HtmlWebpackInlineSourcePlugin()
]  

The above configuration will actually do nothing due to the configuration defaults.

When you set cdnSource to a regular expression the source code for any javascript or css file names that match will be embedded inline in the resulting html document.

plugins: [
  new HtmlWebpackPlugin({
		cdnSource: [{"type":js,"regstr":".*","publicPath":"//1.cdn.xxx.com/"}]
	}),
  new HtmlWebpackInlineSourcePlugin()
]  

About

html-webpack-plugin扩展自定义css js的publicPath 可针对每个js和css设置不同的publicPath用于解决cdn分域名加载的问题

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published