# html-webpack-cdn-path-plugin

> cdn path

Latest version **0.1.3** (published 2017-06-01) · MIT license · 0 weekly downloads

## Install

```sh
npm install html-webpack-cdn-path-plugin
pnpm add html-webpack-cdn-path-plugin
yarn add html-webpack-cdn-path-plugin
bun add html-webpack-cdn-path-plugin
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.1.3 |
| Published | 2017-06-01 |
| First published | 2017-05-31 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 1 |
| Author | drogjh |
| Maintainers | geekbean |
| Keywords | cdn, webpack, path, publicPath, runtime |

## Links

- npm: https://www.npmjs.com/package/html-webpack-cdn-path-plugin
- Repository: https://github.com/drogjh/html-webpack-cdn-path-plugin
- Homepage: https://github.com/drogjh/html-webpack-cdn-path-plugin#readme
- Issues: https://github.com/drogjh/html-webpack-cdn-path-plugin/issues
- npm.io page: https://npm.io/package/html-webpack-cdn-path-plugin

## Alternatives

- [base64url](https://npm.io/package/base64url.md) — 6.1M weekly downloads
- [get-installed-path](https://npm.io/package/get-installed-path.md) — 502.9K weekly downloads
- [@uppy/url](https://npm.io/package/@uppy/url.md) — 185.8K weekly downloads
- [@d3fc/d3fc-shape](https://npm.io/package/@d3fc/d3fc-shape.md) — 16.2K weekly downloads
- [localizer](https://npm.io/package/localizer.md) — 226 weekly downloads

## Recent versions

- 0.1.3 (latest) — 2017-06-01
- 0.1.2 — 2017-05-31
- 0.1.1 — 2017-05-31
- 0.1.0 — 2017-05-31

## README

# html-webpack-cdn-path-plugin

Works with Webpack 2.


## Installation
``` sh
npm i html-webpack-cdn-path-plugin --save-dev
```


## Use
webpack.config.js:

``` javascript
const CdnPathWebpackPlugin = require("html-webpack-cdn-path-plugin");

module.exports = {
    entry: {
        app: ['./main.js'],
    },
    output: {
        filename: '[name].js',
        path: '.dist/',
        publicPath: '/'
    },
    plugins: [
        new CdnPathWebpackPlugin({
            runtimeCdnPath: ['//cdn1.static.com','//cdn2.static.com'],
            assetsJsCdnPath: ['//cdn1.static.com','//cdn2.static.com'],
            assetsCssCdnPath: ['//cdn1.static.com','//cdn2.static.com'],
        })
    ]
}
```


## Result

### 1. manifest (use runtimeCdnPath)
```js
/******/        // __webpack_public_path__
/******/        __webpack_require__.p = "/";

/******/        // publicPath override (html-webpack-cdn-path-plugin)
/******/        __webpack_require__.p = (["//cdn1.static.com","//cdn2.static.com"][Math.floor((Math.random()*2))]+'/') || __webpack_require__.p; // cdn + publicPath
```
### 2. assets js,css
```js
jsUrl = randomAssetsJsCdnPathStr + output.publicPath + output.filename
cssUrl = randomAssetsCssCdnPathStr + output.publicPath + output.filename
```


## License
The [MIT License](LICENSE).


## Thank
- [webpack-runtime-public-path-plugin](https://www.npmjs.com/package/webpack-runtime-public-path-plugin)
- [dynamic-public-path-webpack-plugin](https://www.npmjs.com/package/dynamic-public-path-webpack-plugin)

---
_Source: https://npm.io/package/html-webpack-cdn-path-plugin · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
