项目作者: AMDvsTMD

项目描述 :
html-webpack-plugin扩展自定义css js的publicPath 可针对每个js和css设置不同的publicPath用于解决cdn分域名加载的问题
高级语言: JavaScript
项目地址: git://github.com/AMDvsTMD/html-resource-cdn-plugin.git
创建时间: 2018-04-08T09:15:55Z
项目社区:https://github.com/AMDvsTMD/html-resource-cdn-plugin

开源协议:

下载


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:

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

Add the plugin to your webpack config as follows:

  1. plugins: [
  2. new HtmlWebpackPlugin(),
  3. new HtmlWebpackInlineSourcePlugin()
  4. ]

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.

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