grunt-qiniu-qupload
a grunt plugin which can upload assets to qiniu.
Getting Started
This plugin requires Grunt ~0.4.5
If you haven't used Grunt before, be sure to check out the Getting Started guide, as it explains how to create a Gruntfile as well as install and use Grunt plugins. Once you're familiar with that process, you may install this plugin with this command:
npm install @wangding/grunt-qiniu-qupload --save-dev
Once the plugin has been installed, it may be enabled inside your Gruntfile with this line of JavaScript:
grunt.loadNpmTasks('grunt-qiniu-qupload');
The "qiniu_qupload" task
Overview
In your project's Gruntfile, add a section named qiniu_qupload
to the data object passed into grunt.initConfig()
.
grunt.initConfig({
qiniu_qupload: {
default_options: {
options: {
ak: '<Your AccessKey env var>', // required, default null
sk: '<Your SecretKey env var>', // required, default null
bucket: '<Bucket>', // required, default null
assets: [{ // required, default null
src: 'test/upload/assets', // required
prefix: '', // required, use '' when no prefix
// skip: ['b.css'], // optional, default undefined
}]
}
}
},
});
Options
options.cwd
Type: String
Default value: '.'
current working directory, use to resolve assets path.
options.ak
Type: String
Default value: null
.
options.sk
Type: String
Default value: null
.
options.bucket
Type: String
Default value: null
qiniu bucket where you want to upload your file.
options.assets
Type: Array
Default value: null
your assets. elements in the array must be in struct like {src: '<local assets Dir>', prefix: <Key Prefix>, skip: [<skip files list>]}
, and options.cwd + '<local assets Dir>'
must be an existing assets directory. skip is an optional setting, skip files must in the src
directory. files in skip list will not affect by any operation.
Usage Examples
In this example, the default options are used to upload all the files in 'test/upload/assets/css'
and ''test/upload/assets/js
. Before you run the command grunt
, you have to change the option ak
, sk
and bucket
to your qiniu account setting.
grunt.initConfig({
qiniu_qupload: {
default_options: {
options: {
ak: '<Your AccessKey env var>', // required, default null
sk: '<Your SecretKey env var>', // required, default null
bucket: '<Bucket>', // required, default null
assets: [{ // required, default null
src: 'test/upload/assets', // required
prefix: '', // required, use '' when no prefix
// skip: ['b.css'], // optional, default undefined
}]
}
}
}
});
Contributing
In lieu of a formal styleguide, take care to maintain the existing coding style. Add unit tests for any new or changed functionality. Lint and test your code using Grunt.
Release History
(Nothing yet)