s3-plugin-webpack
s3-plugin-webpack copied to clipboard
Pass "compilation" object into "basePathTransform"
- [x] I have read and understood this plugin's README
- [ ] If filing a bug report, I have included my version of node and s3-plugin-webpack
- [ ] If filing a bug report, I have included which OS (including specific OS version) I am using.
- [ ] If filing a bug report, I have included a minimal test case that reproduces my issue.
- [x] I understand this is an open-source project staffed by someone with a job and that any help I receive is done on free time. I know I am not entitled to anything and will be polite and courteous.
- [x] I understand my issue may be closed if it becomes obvious I didn't actually perform all of these steps or the issue is not with the library itself
Issue Details
It would be nice to have ability to access to compilation
object under basePathTransform
function.
It would be very useful if you would like to use such fields as compilation.fullHash
, compilation.hash
:
new S3Plugin({
basePath: 'test',
basePathTransform: (basePath, compilation) => {
return basePath + compilation.fullHash;
},
s3Options: {
accessKeyId: process.env.AWS_ACCESS_KEY_ID,
secretAccessKey: process.env.AWS_SECRET_ACCESS_KEY,
region: 'us-west-1'
},
s3UploadOptions: {
Bucket: 'MyBucket'
}
})
As alternative you can use https://github.com/webpack/loader-utils#interpolatename to interpolate basePath*
:
new S3Plugin({
basePath: 'test/[hash]',
basePathTransform: basePath => {
return basePath + '[hash]';
},
s3Options: {
accessKeyId: process.env.AWS_ACCESS_KEY_ID,
secretAccessKey: process.env.AWS_SECRET_ACCESS_KEY,
region: 'us-west-1'
},
s3UploadOptions: {
Bucket: 'MyBucket'
}
})
I don't really like the prospect of passing the compilation object around. I do however like the use of interpolateName. I actually only found out about it a couple days ago so I can definitely look into adding that in
@MikaAK Thanks a lot. I will close #46 PR.
Any updates on this? being able to add webpack hash to basePath would be very helpful