sourcemap_upload_aliyunoss_webpack_plugin
webpack(>=2)插件,上传 js 和 js.map 文件到阿里云 oss
Installation
Using npm:
$ npm install @zbyfe/sourcemap_upload_aliyunoss_webpack_plugin --save-dev
Using yarn:
$ yarn add @zbyfe/sourcemap_upload_aliyunoss_webpack_plugin --save-dev
Usage
- webpack usage
const SourceMapPlugin = require('@zbyfe/sourcemap_upload_aliyunoss_webpack_plugin');
const config = {
plugins: [
devtool:'source-map'
new SourceMapPlugin({
host: 'https://xxx.com',
region: 'xxx-xxx-xxx',
accessKeyId: 'xxxxxxx',
accessKeySecret: 'xxxxxx',
bucket: 'xxxxxx',
version: '1.0.2',
project: 'xxx',
env: 'test',
timeout: 30000,
test: false,
include: ['.js', '.js.map'],
ignore: ['node_modules'],
deleteSourceMap: true,
buildDirectory: 'dist'
}),
],
};
- vue usage
const SourcemapPlugin = require("@zbyfe/sourcemap_upload_aliyunoss_webpack_plugin");
module.exports = {
productionSourceMap: true,
configureWebpack: (config) => {
if (process.env.NODE_ENV === "production") {
config.plugins.push(
(host: "https://xxx.com"),
(region: "xxx-xxx-xxx"),
(accessKeyId: "xxxxxxx"),
(accessKeySecret: "xxxxxx"),
(bucket: "xxxxxx"),
(version: "1.0.2"),
(project: "xxx"),
(env: "test"),
(timeout: 30000),
(test: false),
(include: [".js", ".js.map"]),
(ignore: ["node_modules"]),
(deleteSourceMap: true),
(buildDirectory: "dist")
);
}
},
};
- Params
Option | Type | Required | Description |
---|---|---|---|
host | string | required | cdn 域名 |
dist | string | required | 上传到 oss 哪个目录下,默认为 oss 根目录。可作为路径前缀使用 |
region | string | required | 阿里云上传区域 |
accessKeyId | string | required | 阿里云的授权 accessKeyId |
accessKeySecret | string | required | 阿里云的授权 accessKeySecret |
bucket | string | required | 上传到哪个 bucket |
version | string | required | 当前项目版本 |
project | string | required | 当前项目名称 |
env | string | optional | 当前环境,要包含 online 、prod 、pre 、test 、dev 字符串,默认值为production
|
timeout | number | optional | oss 超时设置,默认为 30 秒(30000) |
test | boolean | optional | 测试,仅显示要上传的文件,但是不执行上传操作。默认 false |
include | array/string | optional | 上传文件类型,默认值['.js', '.js.map'] |
ignore | array/string | optional | 忽略上传的文件夹,默认值['node_modules'] |
deleteSourceMap | Boolean | optional | 上传完成后是否删除 sourcemap 文件,默认值 true |
buildDirectory | String | optional | 打包指定生成的目录,e.g. build 、dist
|