aliyun-oss-webpack-plugin
v3.0.2
Published
Aliyun OSS suports for webpack
Downloads
9
Readme
put all bundles except HTML to your aliyun oss.
Installation
webpack 4.x:
npm install aliyun-oss-webpack-plugin --save
webpack 2.x || 3.x:
npm install aliyun-oss-webpack-plugin@"^2.0.1" --save
Configuration
const AliyunOSSPlugin = require("aliyun-oss-webpack-plugin");
module.exports = {
output: {
publicPath: "https://domain.com/p/a/t/h" // !required
},
plugins: [
new AliyunOSSPlugin({
accessKeyId: '*****',
accessKeySecret: '*****',
region: 'oss-cn-hangzhou',
bucket: '*****',
headers: {
'Cache-Control': 'max-age=3600'
}
})
]
}
Example
webpack.config.js
:
const path = require('path');
const AliyunOSSPlugin = require("aliyun-oss-webpack-plugin");
module.exports = {
entry: './src/index.js',
output: {
path: path.resolve(__dirname, './public'),
filename: 'index.js',
publicPath: 'https://my.static.assets.domain/my-project/1.0.0/',
},
plugins: [
new AliyunOSSPlugin({
accessKeyId: '*****',
accessKeySecret: '*****',
region: 'oss-cn-hangzhou',
bucket: '*****',
headers: {
'Cache-Control': 'max-age=3600',
},
})
]
}
index.html
:
<script src="https://my.static.assets.domain/my-project/1.0.0/index.js"></script>