diff --git a/gulpfile.js b/gulpfile.js index 1a09c09..dd13ea4 100755 --- a/gulpfile.js +++ b/gulpfile.js @@ -1,52 +1,53 @@ const gulp = require('gulp'); const gulpSync = require('gulp-sync')(gulp); -const requireDir = require('require-dir'); +const requireTasksDir = require('require-dir'); const packageJson = require('./package.json'); -const baseConfig = { +const config = { + packageJson, port: 3000, phpPort: 3838, - localhost: 'localhost', - packageJson: packageJson, - compressed: true + localhost: 'localhost' }; -const wpThemePath = 'wordpress/wp-content/themes/' + packageJson.name; -const paths = { +const developmentPaths = { + pages: 'src/**/*.php', + fonts: 'src/fonts/**/*.*', + images: 'src/images/**/*.*', + styles: 'src/css/**/*.sass', + scripts: 'src/js/**/*.js' +}; + +const themes = 'wordpress/wp-content/themes/'; +const theTheme = themes + packageJson.name; +const paths = Object.assign({ basePath: 'wordpress/', - pluginsWp: 'plugins/**/*.*', styleWp: 'src/style.css', configWp: 'wp-config.php', - pagesDest: wpThemePath, - fontsDest: wpThemePath + '/fonts', - imagesDest: wpThemePath + '/images', - stylesDest: wpThemePath + '/css', - scriptsDest: wpThemePath + '/js', - themesWp: 'wordpress/wp-content/themes/' -}; + pluginsWp: 'plugins/**/*.*', -const devPaths = { - pages: 'src/**/*.php', - scripts: 'src/js/**/*.js', - styles: 'src/css/**/*.sass', - images: 'src/images/**/*.*', - fonts: 'src/fonts/**/*.*' -}; + themesWp: themes, + pagesDest: theTheme, + fontsDest: `${theTheme}/fonts`, + imagesDest: `${theTheme}/images`, + stylesDest: `${theTheme}/css`, + scriptsDest: `${theTheme}/js` +}, developmentPaths); -gulp.paths = Object.assign(devPaths, paths); -gulp.config = baseConfig; +gulp.paths = paths; +gulp.config = config; -// Gulp tasks -requireDir('tasks'); +requireTasksDir('tasks'); gulp.task('wp', gulpSync.sync(['wp-install'])); gulp.task('default', gulpSync.sync(['build', 'watch', 'connect-sync'])); gulp.task('build', gulpSync.sync(['clean', 'styles', 'scripts', 'pages', 'images', 'fonts', 'libs'])); gulp.task('watch', () => { - gulp.watch(gulp.paths.styles, ['styles']); - gulp.watch(gulp.paths.scripts, ['scripts']); - gulp.watch(gulp.paths.pages, ['pages']); - gulp.watch(gulp.paths.images, ['images']); - gulp.watch(gulp.paths.fonts, ['fonts']); + const paths = Object.keys(developmentPaths); + + paths.map(path => { + // Combine each development path with a task + return gulp.watch(gulp.paths[path], [path]); + }); }); diff --git a/tasks/browser-sync.js b/tasks/browser-sync.js deleted file mode 100755 index b29b7ed..0000000 --- a/tasks/browser-sync.js +++ /dev/null @@ -1,8 +0,0 @@ -const gulp = require('gulp'); -const browserSync = require('browser-sync'); - -gulp.task('browser-sync', function() { - const baseDir = gulp.paths.basePath; - - browserSync({server: {baseDir}}); -}); diff --git a/tasks/connect-sync.js b/tasks/connect-sync.js index 7aeca53..edcb25b 100755 --- a/tasks/connect-sync.js +++ b/tasks/connect-sync.js @@ -12,6 +12,9 @@ gulp.task('connect-sync', function() { connect.server(serverConfig, () => browserSync({ proxy: proxy, - port: gulp.config.port + port: gulp.config.port, + snippetOptions: { + ignorePaths: ['wp-admin/**'] + } })); }); diff --git a/tasks/wp-install.js b/tasks/wp-install.js index ebdfc07..c9bf10c 100644 --- a/tasks/wp-install.js +++ b/tasks/wp-install.js @@ -1,8 +1,7 @@ const gulp = require('gulp'); const request = require('request'); -const zlib = require('zlib'); const fs = require('fs'); -const AdmZip = require('adm-zip'); +const admZip = require('adm-zip'); const readlineSync = require('readline-sync'); const helper = require('./helpers'); @@ -43,7 +42,7 @@ gulp.task('wp-install', function() { helper.log('Unzipping WordPress...', 'success'); - const zip = new AdmZip(outputZip); + const zip = new admZip(outputZip); zip.extractAllTo('./'); fs.unlink(outputZip); diff --git a/tasks/wp-pre-build.js b/tasks/wp-pre-build.js index b79e91a..e461b33 100644 --- a/tasks/wp-pre-build.js +++ b/tasks/wp-pre-build.js @@ -1,5 +1,4 @@ const gulp = require('gulp'); -const plumber = require('gulp-plumber'); const del = require('del'); gulp.task('wp-pre-build', function() {