adrianfalleiro / gulp-s3-publish Goto Github PK
View Code? Open in Web Editor NEWGulp plugin to upload to S3
Gulp plugin to upload to S3
@adrianfalleiro Does it empty the bucket automatically in the background.
var s3 = require("gulp-s3-publish");
gulp.task('deploy', function () {
var aws = JSON.parse(fs.readFileSync('./aws.json'));
gulp.src('./dist/**/*')
.pipe(s3(aws));
});
The task starts and finishes without error but only the first 2 levels of files are uploaded to S3 (./* and ./*/*). Any files nested more deeply appear to be skipped.
This is also an issue in the gulp-s3 plugin, but mentioning it here too.
I've been unable to upload to certain (newer) S3 regions and it is as a result of them only supporting V4. i.e. eu-west-2
(London) as a region, returns an ambiguous HTTP 400 error when attempting to publish files to a bucket in that region.
Message:
[400] C:\file.css.gz -> file.css
Stack:
Error: [400] C:\file.css.gz -> file.css
at DestroyableTransform.uploadCallback (C:\node_modules\gulp-s3-publish\index.js:76:24)
If I only switch the region to e.g. us-east-1
(formerly US Standard which supports V2 and V4) and leave everything else as is, the publish works as expected.
Almost straight from the docs:
try {
console.log("The AWS object is....");
console.log(aws);
var shortOptions = { headers: { 'Cache-Control': 'public, max-age=28800' } }; // 8 hours
gulp.src(['build/dist/**', '!build/dist/*.html'], { read: false })
.pipe(debug())
.pipe(s3(aws, shortOptions));
} catch (error) {
console.log("S3 upload error....");
console.log(error);
}
The output is minimal, no errors to help debug, credentials are good...
[07:44:25] Starting 's3'...
The AWS object is....
{ key: 'AKIAJK6O7IBQXNOTREAL',
secret: '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',
bucket: 'my.validbucket.com',
region: 'us-east-1' }
[07:44:25] Finished 's3' after 26 ms
[07:44:25] gulp-debug: build\dist
[07:44:25] gulp-debug: build\dist\favicon.ico
[07:44:25] gulp-debug: build\dist\fonts
[07:44:25] gulp-debug: build\dist\app-0.3.7.min.css
[07:44:25] gulp-debug: build\dist\app-0.3.7.min.js
[07:44:25] gulp-debug: build\dist\sprite-123.png
Several attempts at bug fixing have been made but with no error messages to go on, this seems fruitless.
As per: nitaigao/gulp-s3#34
e.g. woff2
files will not be published to S3.
Deploying from gulp using this plugin only ever seems to add files. If legacy orphan files exist on the destination they will still be there after deploying from gulp. Currently, I'm having to do the occasional check or even nuke the bucket contents to ensure that this is covered.
What would be really nice is if we could add an option to handle this for us. At its most basic it would involve gulp wiping the bucket contents before upload. A potentially more performant option would be to start by comparing the src and dest directory contents, deleting any orphans that result from that diff and then doing a regular upload (so you only try to delete what really needs to be deleted).
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.