diff --git a/docs/config.md b/docs/config.md index 5963920..57453fe 100644 --- a/docs/config.md +++ b/docs/config.md @@ -64,14 +64,17 @@ The Theme Sync configuration for migrating source files to another project. Once migrated they need to be compiled into dev or production code for that project. -* __enabled__ - (Boolean) value to turn enable "themesync" Gulp task. +* __enabled__ - (Boolean) value to enable "themesync" Gulp task. * __newsite__ - (Boolean) value to enable a gulp task `gulp newsite` for cloning a starterkit into a new project. Requires a `/starterkit/` directory is available such as [https://bitbucket.org/ietwebdev/sitefarm-pattern-lab-one/src/master/starterkit/](https://bitbucket.org/ietwebdev/sitefarm-pattern-lab-one/src/master/starterkit/) * __src__ - (Boolean) False if exporting, or a file path to the source if importing. * __dest__ - Path to the theme directory or new site. Make sure the path ends in a /. +* __sassSync__ - (Boolean) Set to True (default) if the `sass` directories should be synced. * __sassSrc__ - Path to find the SASS. * __sassDest__ - Path to place the SASS in destination. +* __jsSync__ - (Boolean) Set to True (default) if the `js` directories should be synced. * __jsSrc__ - Path to find the JavaScript. * __jsDest__ - Path to place the JavaScript in destination. +* __imagesSync__ - (Boolean) Set to True (default) if the `images` directories should be synced. * __imagesSrc__ - Path to find the images. * __imagesDest__ - Path to place the images in destination. diff --git a/gulp-config.default.js b/gulp-config.default.js index 2e843b4..199c719 100644 --- a/gulp-config.default.js +++ b/gulp-config.default.js @@ -85,10 +85,13 @@ module.exports = { newsite: false, src: false, dest: '../theme/', + sassSync: true, sassSrc: 'source/sass/', sassDest: 'sass/1_pattern_lab/', + jsSync: true, jsSrc: 'source/js/', jsDest: 'js/1_pattern_lab/', + imagesSync: true, imagesSrc: 'source/images/', imagesDest: 'images/' }, diff --git a/gulp_tasks/theme-sync.js b/gulp_tasks/theme-sync.js index 6a1faa5..846d3f5 100644 --- a/gulp_tasks/theme-sync.js +++ b/gulp_tasks/theme-sync.js @@ -24,23 +24,32 @@ module.exports = function (gulp, config, tasks) { } // Delete and replace the Sass directory. - del(sassDest, {force: true}).then(() => { - copy(sassSrc, sassDest, {overwrite: true}).catch(function(error) { - console.error('Sass directory Copy failed: ' + error); + if (config.themeSync.sassSync) { + del(sassDest, {force: true}).then(() => { + copy(sassSrc, sassDest, {overwrite: true}).catch(function (error) { + console.error('Sass directory Copy failed: ' + error); + }); }); - }); + } // Delete and replace the Js directory. - del(jsDest, {force: true}).then(() => { - copy(jsSrc, jsDest, {overwrite: true}).catch(function(error) { - console.error('Sass directory Copy failed: ' + error); + if (config.themeSync.jsSync) { + del(jsDest, {force: true}).then(() => { + copy(jsSrc, jsDest, {overwrite: true}).catch(function (error) { + console.error('Sass directory Copy failed: ' + error); + }); }); - }); + } // Copy Images directory (but don't delete the directory first). - copy(imagesSrc, imagesDest, {overwrite: true, filter: ['**/*', '!sample/**/*', '!sample' ]}).catch(function(error) { - console.error('Images directory Copy failed: ' + error); - }); + if (config.themeSync.imagesSync) { + copy(imagesSrc, imagesDest, { + overwrite: true, + filter: ['**/*', '!sample/**/*', '!sample'], + }).catch(function (error) { + console.error('Images directory Copy failed: ' + error); + }); + } });