From eeb532b80903b6ff222cac2eec3b786dfba98679 Mon Sep 17 00:00:00 2001 From: Oliver Davies Date: Wed, 3 Feb 2016 19:24:47 +0000 Subject: [PATCH] Split vendor and site assets --- gulp/build.coffee | 2 +- gulp/clean.coffee | 8 +++++++- gulp/scripts.coffee | 10 ---------- gulp/styles.coffee | 9 +-------- gulp/vendor.coffee | 15 +++++++++++++++ gulpfile.coffee | 23 +++++++++++++++++++++-- sass/{styles.scss => site.scss} | 7 ++++--- sass/vendor.scss | 4 ++++ source/_layouts/default.html.twig | 5 +++-- 9 files changed, 56 insertions(+), 27 deletions(-) create mode 100644 gulp/vendor.coffee rename sass/{styles.scss => site.scss} (78%) create mode 100644 sass/vendor.scss diff --git a/gulp/build.coffee b/gulp/build.coffee index 99d54b39..62aefcea 100644 --- a/gulp/build.coffee +++ b/gulp/build.coffee @@ -1,4 +1,4 @@ g = require 'gulp' g.task 'build', -> - g.start 'clean', 'styles', 'scripts', 'fonts' + g.start 'clean', 'vendor', 'styles', 'fonts' diff --git a/gulp/clean.coffee b/gulp/clean.coffee index ae31b1a5..eead95c6 100644 --- a/gulp/clean.coffee +++ b/gulp/clean.coffee @@ -1,5 +1,11 @@ g = require 'gulp' g.task 'clean', -> - g.src "{output_*,source}/assets/{css,fonts,js}", read: false + g.src [ + 'output_*/assets/css', + 'output_*/assets/fonts', + 'source/assets/css', + 'source/assets/fonts', + 'source/assets/js', + ], read: false .pipe g.p.clean() diff --git a/gulp/scripts.coffee b/gulp/scripts.coffee index b35ac2dc..e69de29b 100644 --- a/gulp/scripts.coffee +++ b/gulp/scripts.coffee @@ -1,10 +0,0 @@ -g = require 'gulp' - -g.task 'scripts', => - g.src ['vendor/bower/jquery/dist/jquery.js', 'vendor/bower/bootstrap-sass/assets/javascripts/bootstrap.js'] - .pipe g.p.plumber() - .pipe g.p.if g.config.sourceMaps, g.p.sourcemaps.init() - .pipe g.p.concat 'all.js' - .pipe g.p.if g.config.production, g.p.uglify() - .pipe g.p.if g.config.sourceMaps, g.p.sourcemaps.write('.') - .pipe g.dest 'source/assets/js' diff --git a/gulp/styles.coffee b/gulp/styles.coffee index 283d373e..ff756e2f 100644 --- a/gulp/styles.coffee +++ b/gulp/styles.coffee @@ -1,11 +1,4 @@ g = require 'gulp' g.task 'styles', -> - g.src ['vendor/bower/font-awesome/css/font-awesome.css', 'sass/styles.scss'] - .pipe g.p.plumber() - .pipe g.p.if g.config.sourceMaps, g.p.sourcemaps.init() - .pipe g.p.sass() - .pipe g.p.concat 'all.css' - .pipe g.p.if g.config.sourceMaps, g.p.sourcemaps.write('.') - .pipe g.dest 'source/assets/css' - .pipe g.p.if g.config.livereload, g.p.livereload() + g.css 'sass/site.scss', 'site.css' diff --git a/gulp/vendor.coffee b/gulp/vendor.coffee new file mode 100644 index 00000000..83b9a4b5 --- /dev/null +++ b/gulp/vendor.coffee @@ -0,0 +1,15 @@ +g = require 'gulp' + +g.task 'vendor', -> g.start 'vendor-styles', 'vendor-scripts' + +g.task 'vendor-styles', -> + g.css [ + 'sass/vendor.scss', + 'vendor/bower/font-awesome/css/font-awesome.css' + ], 'vendor.css' + +g.task 'vendor-scripts', => + g.js [ + 'vendor/bower/jquery/dist/jquery.js', + 'vendor/bower/bootstrap-sass/assets/javascripts/bootstrap/collapse.js', + ], 'vendor.js' diff --git a/gulpfile.coffee b/gulpfile.coffee index bdbce1e4..59c88aad 100644 --- a/gulpfile.coffee +++ b/gulpfile.coffee @@ -11,7 +11,26 @@ g.config = liveReload: !g.p.util.env.production g.copy = (srcFiles, outputDir) -> - g.src(srcFiles) - .pipe g.dest(outputDir) + g.src srcFiles + .pipe g.dest outputDir + +g.css = (srcFiles, destFile) -> + g.src srcFiles + .pipe g.p.plumber() + .pipe g.p.if g.config.sourceMaps, g.p.sourcemaps.init() + .pipe g.p.sass() + .pipe g.p.concat destFile + .pipe g.p.if g.config.sourceMaps, g.p.sourcemaps.write('.') + .pipe g.dest 'source/assets/css' + .pipe g.p.if g.config.livereload, g.p.livereload() + +g.js = (srcFiles, destFile) -> + g.src srcFiles + .pipe g.p.plumber() + .pipe g.p.if g.config.sourceMaps, g.p.sourcemaps.init() + .pipe g.p.concat destFile + .pipe g.p.if g.config.production, g.p.uglify() + .pipe g.p.if g.config.sourceMaps, g.p.sourcemaps.write('.') + .pipe g.dest 'source/assets/js' require('fs').readdirSync('./gulp').forEach (task) -> require "./gulp/#{task}" diff --git a/sass/styles.scss b/sass/site.scss similarity index 78% rename from sass/styles.scss rename to sass/site.scss index 69b88e1e..7648fcd8 100644 --- a/sass/styles.scss +++ b/sass/site.scss @@ -1,7 +1,8 @@ -@import '_variables'; - +@import '../vendor/bower/bootstrap-sass/assets/stylesheets/bootstrap/variables'; +@import '../vendor/bower/bootstrap-sass/assets/stylesheets/bootstrap/mixins/clearfix'; @import '../vendor/bower/compass-breakpoint/stylesheets/breakpoint'; -@import '../vendor/bower/bootstrap-sass/assets/stylesheets/bootstrap'; + +@import '_variables'; @import 'partials/base'; @import 'partials/badges'; diff --git a/sass/vendor.scss b/sass/vendor.scss new file mode 100644 index 00000000..a808a5e7 --- /dev/null +++ b/sass/vendor.scss @@ -0,0 +1,4 @@ +@import '_variables'; + +@import '../vendor/bower/compass-breakpoint/stylesheets/breakpoint'; +@import '../vendor/bower/bootstrap-sass/assets/stylesheets/bootstrap'; diff --git a/source/_layouts/default.html.twig b/source/_layouts/default.html.twig index 10fcbd44..d736d3e3 100644 --- a/source/_layouts/default.html.twig +++ b/source/_layouts/default.html.twig @@ -18,7 +18,8 @@ - + + {% block styles %}{% endblock %} {% for size in site.apple_touch_icon_sizes %} @@ -90,7 +91,7 @@ {% include('meetups') %} - + {% block scripts %}{% endblock %}