Easily deploy single page applications to S3 + CloudFront.
note: This is very much a work in progress, don't expect anything to work right now
npm install --global cadmium
To deploy the app in the current directory, invoke cadmium deploy
:
cadmium deploy --s3-bucket=website --cloudfront-distribution-id=C991478EDD28R
Cadmium currently uses some very opinionated defaults:
-
dist/main.js
will be revhashed and uploaded to/main-${revHash}.js
-
app.html
will be minified and uploaded asindex.html
, withsrc="/main.js"
replaced by the path to the above file - Every file in
assets/
with a rev hash in the filename will be uploaded to/
- e.g.
assets/close-2f3235788c.svg
will be served at/close-2f3235788c.svg
- if the file content doesn't match the revhash, an error will be thrown
- e.g.
- Every file in
well-known/
will be uploaded to/.well-known
Every revhashed file will only be uploaded if it doesn't already exists. app.html
, and well-known
-files, will always be uploaded.
The algorithm used for revhashing is the rev-hash package, which takes an md5 sum and truncates it to 10 characters.
When everything is uploaded an invalidation for the path /
and /.well-known/*
will be issued to the CloudFront distribution. Since every other file is revhashed every subsequent visit should now be the latest version.
To serve the app locally, invoke cadmium serve
:
cadmium serve --port=3000
This command will start an http server that will match the behaviour that you should see from a site deployed to S3 + CloudFront.