From fdb79beb79fa9445930dd562ea39d634a66b23cd Mon Sep 17 00:00:00 2001 From: Jeff Avallone Date: Sun, 1 Nov 2015 07:39:33 -0500 Subject: [PATCH] Reworking how styles are built and how SVG styles are included --- .gitignore | 1 + config.js | 1 + gulpfile.js | 34 +++++++++++++++++++++++++++++----- lib/data/svg_styles.js | 7 ------- lib/partials/svg_template.hbs | 2 +- 5 files changed, 32 insertions(+), 13 deletions(-) delete mode 100644 lib/data/svg_styles.js diff --git a/.gitignore b/.gitignore index 36c3cf0..8dd770b 100644 --- a/.gitignore +++ b/.gitignore @@ -2,3 +2,4 @@ node_modules .sass-cache build docs +tmp diff --git a/config.js b/config.js index ba8d976..43177a5 100644 --- a/config.js +++ b/config.js @@ -13,6 +13,7 @@ module.exports = { helpers: './lib/helpers/**/*.js', partials: './lib/partials/**/*.hbs', sass: './src/**/*.scss', + svg_sass: './src/sass/svg.scss', js: ['./src/**/*.js', './src/**/*.peg'], spec: './spec/**/*_spec.js' }, diff --git a/gulpfile.js b/gulpfile.js index fbd99af..2ecbb50 100644 --- a/gulpfile.js +++ b/gulpfile.js @@ -10,8 +10,9 @@ gulp.task('default', ['server', 'docs'], function() { config.globs.data, config.globs.helpers, config.globs.partials, - config.globs.sass + config.globs.svg_sass ]), ['markup']); + gulp.watch(config.globs.sass, ['styles']); gulp.watch(config.globs.js, ['scripts', 'docs']); }); @@ -51,7 +52,7 @@ gulp.task('static', function() { .pipe(gulp.dest(config.buildRoot)); }); -gulp.task('markup', ['styles'], function() { +gulp.task('markup', ['markup:svg_styles'], function() { var hb = require('gulp-hb'), frontMatter = require('gulp-front-matter'), rename = require('gulp-rename'); @@ -61,8 +62,14 @@ gulp.task('markup', ['styles'], function() { .pipe(hb({ data: config.globs.data, helpers: config.globs.helpers, - partials: config.globs.partials, - bustCache: true, + partials: _.flatten([ + config.globs.partials, + './tmp/build/svg_styles.hbs' + ]), + parsePartialName: function(file) { + return _.last(file.shortPath.split('/')); + }, + bustCache: true })) .on('error', notify.onError()) .pipe(rename(function(path) { @@ -71,12 +78,29 @@ gulp.task('markup', ['styles'], function() { .pipe(gulp.dest(config.buildRoot)); }); +gulp.task('markup:svg_styles', function() { + var sass = require('gulp-sass'), + rename = require('gulp-rename'); + + return gulp.src('./src/sass/svg.scss') + .pipe(sass({ + includePaths: require('node-bourbon').includePaths + })) + .on('error', notify.onError()) + .pipe(rename(function(path) { + path.dirname = ''; + path.basename = 'svg_styles'; + path.extname = '.hbs'; + })) + .pipe(gulp.dest('./tmp/build')) +}); + gulp.task('styles', function() { var sourcemaps = require('gulp-sourcemaps'), sass = require('gulp-sass'), rename = require('gulp-rename'); - return gulp.src(config.globs.sass) + return gulp.src('./src/sass/main.scss') .pipe(sourcemaps.init()) .pipe(sass({ includePaths: require('node-bourbon').includePaths diff --git a/lib/data/svg_styles.js b/lib/data/svg_styles.js deleted file mode 100644 index 1ccaebc..0000000 --- a/lib/data/svg_styles.js +++ /dev/null @@ -1,7 +0,0 @@ -var fs = require('fs'), - path = require('path'), - config = require('../../config'); - -module.exports = fs.readFileSync(config.buildPath('css/svg.css'), { - encoding: 'utf-8' -}); diff --git a/lib/partials/svg_template.hbs b/lib/partials/svg_template.hbs index a6e3f31..4a24b5e 100644 --- a/lib/partials/svg_template.hbs +++ b/lib/partials/svg_template.hbs @@ -5,7 +5,7 @@ xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" version="1.1"> - +