Minify HTML

This commit is contained in:
Oliver Davies 2016-01-11 02:28:43 +00:00
parent 8bf421adba
commit 508e407faf
5 changed files with 12 additions and 10 deletions

View file

@ -81,6 +81,12 @@ gulp.task('clean', function () {
del.sync('./output_*/assets/fonts/*');
});
gulp.task('minify-prod-html', function() {
gulp.src('output_prod/**/*.html')
.pipe(plugins.htmlmin({ collapseWhitespace: true }))
.pipe(gulp.dest('output_prod'));
});
gulp.task('build', ['clean', 'styles', 'scripts', 'fonts']);
gulp.task('default', ['build', 'watch']);

View file

@ -3,6 +3,7 @@
"del": "^2.2.0",
"gulp": "^3.9.0",
"gulp-concat": "^2.6.0",
"gulp-htmlmin": "^1.3.0",
"gulp-if": "^2.0.0",
"gulp-imagemin": "^2.4.0",
"gulp-livereload": "^3.8.1",

View file

@ -11,5 +11,8 @@ gulp build --production
./vendor/bin/sculpin generate --env=${ENV} --clean --no-interaction
if [ $? -ne 0 ]; then echo "Could not generate the site"; exit 1; fi
# Minify HTML.
gulp minify-prod-html
rsync -av --delete output_${ENV}/ ${DEPLOY_USER}@${DEPLOY_HOST}:${DEPLOY_PATH}
if [ $? -ne 0 ]; then echo "Could not publish the site"; exit 1; fi

View file

@ -99,15 +99,7 @@
{% endif %}
{% if site.google_analytics_tracking_id %}
<script>
(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
})(window,document,'script','//www.google-analytics.com/analytics.js','ga');
ga('create', '{{ site.google_analytics_tracking_id }}', 'auto');
ga('send', 'pageview');
</script>
<script>(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){ (i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m) })(window,document,'script','//www.google-analytics.com/analytics.js','ga'); ga('create', '{{ site.google_analytics_tracking_id }}', 'auto'); ga('send', 'pageview');</script>
{% endif %}
</body>
</html>

View file

@ -19,7 +19,7 @@ use:
{% if post.blocks.excerpt %}
{{ post.blocks.excerpt|raw }}
{% else %}
<p>{{ post.blocks.content|raw|split(' ')|slice(0,50)|join(' ')|replace({ 'h2':'h3' })|raw }} &hellip;</p>
<p>{{ post.blocks.content|raw|striptags|split(' ')|slice(0,50)|join(' ')|replace({ 'h2':'h3' }) }} &hellip;</p>
{% endif %}
<a href="{{ post.url }}">Read more &rarr;</a>