Skip to content

Commit

Permalink
Merge pull request #37 from pipocadigital/fix/wp-copy
Browse files Browse the repository at this point in the history
Copy `plugins/` using npm scripts and fix `style.css` bug
  • Loading branch information
alanfabiano authored Mar 7, 2018
2 parents 8d43012 + 8c7fc9f commit d266ff0
Show file tree
Hide file tree
Showing 6 changed files with 27 additions and 33 deletions.
2 changes: 1 addition & 1 deletion gulpfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ const packageJson = require('./package.json');
let defaultTasks = ['build', 'watch', 'connect-sync'];

if (packageJson.projectFormat === 'wordpress') {
defaultTasks.push('wp-build');
defaultTasks.push('wp-pre-build');
}

const baseConfig = {
Expand Down
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,10 @@
"serve": "gulp",
"init": "gulp init --name",
"start": "npm install && bower install && npm run init",
"wp": "gulp set-format --name \"wordpress\" && gulp wp-install && gulp wp-build",
"wp": "gulp set-format --name \"wordpress\" && gulp wp-install && gulp wp-pre-build && npm run wp:plugins",
"wp:dev": "npm run wp && gulp",
"wp:build": "npm run wp && gulp build",
"wp:plugins": "cp -r ./plugins ./wordpress/wp-content",
"front": "gulp set-format --name \"default\"",
"front:dev": "npm run front && gulp",
"front:build": "npm run front && gulp build"
Expand Down
Empty file added plugins/.gitkeep
Empty file.
17 changes: 14 additions & 3 deletions tasks/styles.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,9 @@ const sassLint = require('gulp-sass-lint');
const browserSync = require('browser-sync');

gulp.task('styles', function() {
return gulp.src(gulp.paths.styles)
const {paths} = gulp;

gulp.src(paths.styles)
.pipe(plumber({
errorHandler: error => {
console.log(error.message);
Expand All @@ -25,6 +27,15 @@ gulp.task('styles', function() {
.pipe(sourcemaps.write('.', {
mapFile: mapFilePath => mapFilePath.replace('.js.map', '.map')
}))
.pipe(gulp.dest(gulp.paths.stylesDest))
.pipe(browserSync.reload({stream: true}))
.pipe(gulp.dest(paths.stylesDest))
.pipe(browserSync.reload({stream: true}));

gulp.src('src/style.css')
.pipe(plumber({
errorHandler: error => {
console.log(error.message);
this.emit('end');
}
}))
.pipe(gulp.dest(paths.pagesDest));
});
28 changes: 0 additions & 28 deletions tasks/wp-build.js

This file was deleted.

10 changes: 10 additions & 0 deletions tasks/wp-pre-build.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
const gulp = require('gulp');
const plumber = require('gulp-plumber');
const del = require('del');

gulp.task('wp-pre-build', function() {
const gulpPaths = gulp.paths;
const packageJson = gulp.config.packageJson;

del([gulpPaths.themesWp + '*', '!' + gulpPaths.themesWp + packageJson.name, '!' + gulpPaths.themesWp + 'index.php']);
});

0 comments on commit d266ff0

Please sign in to comment.