Sign Up for Free

RunKit +

Try any Node.js package right in your browser

This is a playground to test code. It runs a full Node.js environment and already has all of npm’s 1,000,000+ packages pre-installed, including tencent-cos-webpack-plugin with all npm packages installed. Try it out:

var tencentCosWebpackPlugin = require("tencent-cos-webpack-plugin")

This service is provided by RunKit and is not affiliated with npm, Inc or the package authors.

tencent-cos-webpack-plugin v0.0.4

tencent cos webpack plugin

npm version downloads Build Status License

Tecent COS Webpack Plugin

Upload the webpack build assets to Tencent COS, make it convinent to use CDN.

Quick Start

// import TencentCosWebpackPlugin
const TencentCosWebpackPlugin = require('tenent-cos-webpack-plugin');

// Instantiate the Plugin with your COS auth info
const cosPlugin = new CosPlugin({
  secretId: 'my-secret-id', // usual use BucketName-APPID. refer: https://cloud.tencent.com/document/product/436/36119#.E7.AE.80.E5.8D.95.E4.B8.8A.E4.BC.A0.E5.AF.B9.E8.B1.A1
  secretKey: 'my-secret-key',
  bucket: 'my-125000000',
  region: 'ap-chengdu',
  path: 'xxx/' // the sub directory in the COS bucket, its default value is "[hash]/" which indicate the webpack build hash
  changeFileName: Function, // change the filename under COS path。
  proxy: 'xxx.proxy.com' // your http/https proxy
  exclude: /\.map$/ // which file to exclude
});

// Webpack config
module.exports = {
 output: {
    // your cos domain
    publicPath: "http://www.abc.com"
    // ...
 },
 plugins: [
   cosPlugin
   // ...
 ]
 // ...
}

Contribute

  • fork the repo

  • clone your repo

git clone https://github.com/xxxx/tencent-cos-webpack-plugin # clone the repo
  • install dep
npm install # install dep
  • coding

  • lint & test

write unit test and execute it

npm run lint
npm run test
  • put a pull request

Thanks

thanks to the repostory cos-webpack. I just change the output filename logic.

RunKit is a free, in-browser JavaScript dev environment for prototyping Node.js code, with every npm package installed. Sign up to share your code.
Sign Up for Free