eslint
OSS , webpack webpack OSS
** webpack 345**
abc.js
hash , existCheck: false
:
js``css
hash
, eg: detail-question.34d71b4.js
html
url-loader
js (base64)accessKey
npm install -D webpack-alioss-plugin
:
webpackConfig.output.publicPath
prefix
oss url, eg:'//res.xueboren.com/auto_upload_ci/your-project-name/'
: (****)
// CI :
// WEBPACK_ALIOSS_PLUGIN_ACCESS_KEY_ID accessKeyId
// WEBPACK_ALIOSS_PLUGIN_ACCESS_KEY_SECRET accessKeySecret
// WEBPACK_ALIOSS_PLUGIN_BUCKET bucket
// WEBPACK_ALIOSS_PLUGIN_REGION region
// (, 'auto_upload_ci') WEBPACK_ALIOSS_PLUGIN_OSS_BASE_DIR ossBaseDir
const AliOSSPlugin = require('webpack-alioss-plugin')
webpackConfig.plugins.push(new AliOSSPlugin())
:
const AliOSSPlugin = require('webpack-alioss-plugin')
webpackConfig.plugins.push(new AliOSSPlugin({
auth: {
accessKeyId: '', // OSS
accessKeySecret: '', // OSS
region: 'oss-cn-hangzhou', // OSS , : oss-cn-hangzhou
bucket: 'abc', // OSS , OSS
},
ossBaseDir: 'auto_upload_ci',
project: 'my-project-name', // ()
}))
const WebpackAliossPlugin = require('webpack-alioss-plugin');
const isProduction = process.env.NODE_ENV === 'production';
module.exports = {
publicPath: isProduction ? '//res.xueboren.com/auto_upload_ci/your-project-name/' : '',
configureWebpack: {
plugins: isProduction ? [
new WebpackAliossPlugin(),
] : [],
},
};
OSS accessKey accessKeySecret , ,
:
| | | |
--- | --- | --- | --- |
accessKeyId | WEBPACK_ALIOSS_PLUGIN_ACCESS_KEY_ID
| | OSS key |
accessKeySecret | WEBPACK_ALIOSS_PLUGIN_ACCESS_KEY_SECRET
| | OSS secret |
bucket | WEBPACK_ALIOSS_PLUGIN_BUCKET
| | OSS |
region | WEBPACK_ALIOSS_PLUGIN_REGION
| | OSS |
exclude | - | /.*\.html$/
| OSS |
retry | - | 3 | , 0 |
gzip | - | true
| gzip |
existCheck | - | true
| (, ) |
enableLog | WEBPACK_ALIOSS_PLUGIN_ENABLE_LOG
| false | |
ignoreError | WEBPACK_ALIOSS_PLUGIN_IGNORE_ERROR
| false | webpack |
removeMode | WEBPACK_ALIOSS_PLUGIN_REMOVE_MODE
| true | OSS , |
prefix() | | WEBPACK_ALIOSS_PLUGIN_PREFIX
false | ~~, , accessKey
~~ |
ossBaseDir | WEBPACK_ALIOSS_PLUGIN_OSS_BASE_DIR
| auto_upload_ci
| OSS |
project | - | package.json
name
| OSS , |
options | - | undefined | . |
envPrefix | - | ''
| . key() |
accessKey
~~