# multi-path-webpack-plugin

> a webpack plugin for multi level path deploy, replace absolute static path

Latest version **1.0.7** (published 2017-06-23) · ISC license · 0 weekly downloads

## Install

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

## Health

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

Positive: no vulnerabilities.

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

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.7 |
| Published | 2017-06-23 |
| First published | 2017-06-16 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 7 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Author | mj |
| Maintainers | zoumiaojiang |
| Keywords | webpack, plugin, multi level path |

## Links

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

## Dependencies (7)

- [minimatch](https://npm.io/package/minimatch.md) ^3.0.4
- [babel-core](https://npm.io/package/babel-core.md) ^6.24.1
- [babel-preset-env](https://npm.io/package/babel-preset-env.md) ^1.3.2
- [babel-preset-latest](https://npm.io/package/babel-preset-latest.md) ^6.24.1
- [babel-plugin-external-helpers](https://npm.io/package/babel-plugin-external-helpers.md) ^6.22.0
- [babel-plugin-transform-runtime](https://npm.io/package/babel-plugin-transform-runtime.md) ^6.23.0
- [babel-plugin-transform-object-rest-spread](https://npm.io/package/babel-plugin-transform-object-rest-spread.md) ^6.23.0

## 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

- 1.0.7 (latest) — 2017-06-23
- 1.0.6 — 2017-06-23
- 1.0.5 — 2017-06-22
- 1.0.4 — 2017-06-22
- 1.0.3 — 2017-06-21
- 1.0.2 — 2017-06-19
- 1.0.1 — 2017-06-16
- 1.0.0 — 2017-06-16

## README

# multi-path-webpack-plugin

解决 webpack 项目需要多级 path 部署时的全局静态资源绝对路径替换的问题

## Usage

### 安装

```bash
npm install --save-dev multi-path-webpack-plugin
```

### 注册 pligin

```
// ...
var MulitPathWebpackPlugin = require('multi-path-webpack-plugin');
// ...

webpack({
    // ...
    plugins: [
        // ...
        // 放在插件数组的组后面
        new MultiPathWebpackPlugin({/* options */})
    ]

    // ...
})
```

## options 参数

### prefix

通常，如果我们的 html 是由 [html-webpack-plugin](https://github.com/jantimon/html-webpack-plugin) 生成的话，我们必须将配置配成 `webpack-html-plugin` 的 prefix，即 `assetPublicPath`

```js
{
    prefix: config.build.assetPublicPath
}
```
其他场景可以自定义指定 `prefix`


###  ignore

ignore 参数可以指定你不想替换静态资源的 path 的规则，规则同 [minimatch](https://github.com/isaacs/minimatch)

```
{
    ignore: [
        '*.map',
        '**/*.map'
    ]
}
```


## note 注意事项

插件采取的是全局正则替换方案，能够找到 `"/a/b/c"`, `'/a/b/c'`, `(/a/b/c)`, `=/a/b/c` 类型的绝对路径 path， 当不需要替换的绝对路径，请避免这些写法。

下列实例请在开发中操作绝对路径时参考：

``` js
// 如果 prefix 为 /prefix/

var path = '/a/b/c.js';
// 转成 /prefix/a/b/c.js

var path1 = "/a/b/c.js";
// 转成 /prefix/a/b/c.js


<link href=/a/b/c ...>
// 转成 <link href=/prefix/a/b/c>

background: url(/a/b/c.png);
// 转成 background: url(/prefix/a/b/c.png);

```

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