# uploadsm-webpack-plugin

> 一个webpack打包后上传sourcemap的插件

Latest version **1.0.2** (published 2021-03-15) · ISC license · 0 weekly downloads

## Install

```sh
npm install uploadsm-webpack-plugin
pnpm add uploadsm-webpack-plugin
yarn add uploadsm-webpack-plugin
bun add uploadsm-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.2 |
| Published | 2021-03-15 |
| First published | 2021-03-15 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 3 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | elester |
| Maintainers | elester |

## Links

- npm: https://www.npmjs.com/package/uploadsm-webpack-plugin
- npm.io page: https://npm.io/package/uploadsm-webpack-plugin

## Recent versions

- 1.0.2 (latest) — 2021-03-15
- 1.0.1 — 2021-03-15
- 1.0.0 — 2021-03-15

## README

# 简介

利用此插件在webpack打包的时候将sourcemap文件上传到配置的URL中,node端接受固定路径为/saveSourceMap

### 示例用法

```
// webpack.config.js
const UploadsmWebpackPlugin = require('uploadsm-webpack-plugin')
module.exports = {
    ....
    plugin:{
        new UploadsmWebpackPlugin({
            postUrl: 'http://127.0.0.1:3000'
        })
    }
}

// node router.js
const multiparty = require('multiparty')
const fs = require('fs')
const path = require('path')

router.post('/saveSourceMap',function(req,res){
    let form = new multiparty.Form();

    form.parse(req, function(err,fields,files){
        for(let item in files){
            let inputFile = files[item][0];
            let uploadedPath = inputFile.path;
            // ./sourcemap是存放sourcemap的文件夹
            let distPath = path.join(path.resolve(__dirname,'./sourcemap'),inputFile.originalFilename)
            let readStream=fs.createReadStream(uploadedPath);
            let writeStream=fs.createWriteStream(distPath);
            readStream.pipe(writeStream);
            readStream.on('end',function(){
                fs.unlinkSync(uploadedPath);
            });
        }  
        res.send('数据已接收');
    })
})
```

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