Optimize assets and deploy your static website.
- Use only commited files
- Minify CSS and use MD5 hash as file name
- Minify JS and use MD5 hash as file name
- Optimize images (JPG, PNG)
- Set noindex and nofollow for non production environment
Example output:
$ ./deploy.rb -v
Deploying to staging.example.com...
Do you want to commmit changes first? [yN] n
>> Cleaning old build...
>> Cloning commited files...
>> Minify CSS...
>> Use MD5 hash for minified CSS...
>> Remove SASS files...
>> Minify CSS...
>> Use MD5 hash for minified JS...
>> Optimize JPGs...
>> Optimize PNGs...
>> Set noindex and nofollow for staging environment...
>> Uploading...
Successfully deployed.
Some system tools are needed:
minify
for minifying your assetsmd5sum
for generating md5 hashes of your assetssed
for changing your HTML files for the optimized assetsjpgoptim
for optimizing your JPG files (progress, 90%)optipng
for optimizing your PNG filesrsync
for uploading to your server
- Install ruby
- Install dependencies
- Clone
git clone https://github.com/DSIW/swd.git
- Put
deployment.json
anddeploy.rb
in your project directory - Make changes in
deployment.json
$ deploy.rb --help
Usage: deploy.rb [options] [staging|production]
Optimize assets and deploy your static website.
Options:
-c, --config Config file (default: deployment.json)
-n, --[no-]dry-run Run without actions
-v, --[no-]verbose Run verbosely
Note: Maybe some other improvements of your site are recommended:
- Activate compression on Server for HTML, SVG,... files.
- Use browser caching
- Set the robots meta tag if you like. The robots.txt will be ignored if your site is linked.
- Set favicon using Favicon Generator
- Activate HTTPS by using the great Let's Encrypt
The website code needs to be in src/
. Your site will be changed in build/
. The following project structure
corresponds to the example deployment.json
.
project/
src/
assets/
css/
js/
images/
index.html
build/
...
Some additional features would be nice:
- Use only commited files for the deployment
- Parse CSS, JS and images folder from HTML files
- Deploy to gh-pages
Contribution is very welcome! Create an issue or pull request!
- Fork it
- Create your feature branch (
git checkout -b feature-[short_description]
orgit checkout -b fix-[github_issue_number]-[short_description]
) - Commit your changes (
git commit -am 'Add some missing feature'
) - Push to the branch (
git push origin [branch-name]
) - Create new Pull Request
MIT License
Copyright (c) 2017 DSIW
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.