Skip to content
This repository has been archived by the owner on Apr 27, 2021. It is now read-only.

Commit

Permalink
Update meta information handling.
Browse files Browse the repository at this point in the history
  • Loading branch information
kris-ellery committed Oct 11, 2015
1 parent 49026f9 commit e4b42fb
Show file tree
Hide file tree
Showing 4 changed files with 81 additions and 48 deletions.
66 changes: 44 additions & 22 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,21 +4,23 @@

* Dependencies
* WordPress
* Build
* Server
* Assets
* Meta Information
* Default Task
* Build Task
* Server Task
* Assets Task
* Data
* Fonts
* Images
* Media
* Miscellaneous
* Vendors
* Scripts
* Scripts Task
* Style Guide
* Styles
* Styles Task
* Structure
* Style Guide
* Views
* Views Task

---

Expand All @@ -36,23 +38,37 @@ You have to install WordPress inside `./build` directory and create a local MySQ

---

## Build
## Meta Information

Open `./package.json` file and set your project details (`name`, `description`, `version`, `author`, etc.). This information will be used to set your theme directory and CSS/JS headers.

---

## Default Task

This task will run `build` and `server` tasks.

Run: `gulp`

---

## Build Task

This task will generate a fresh build of your project. It will run several individual tasks on files within `./source` and then output them to `./build/wp-content/themes/{custom-name}`.

Run: `gulp build`

---

## Server
## Server Task

This task will start a local Node server for development purposes. Mamp URL must match proxy in `./server.js`. By default it's set to `http://localhost:8888/`. Also, Mamp needs to point to `./build` directory (WordPress root).

Run: `gulp server`

---

## Assets
## Assets Task

This task will run several individual sub-tasks to copy static files from `./source` to `./build/wp-content/themes/{custom-name}`.

Expand Down Expand Up @@ -88,6 +104,12 @@ This task will copy miscellaneous WordPress files, such as `style.css` or `scree

Run: `gulp misc`

### Meta

This task will add meta information to default `style.css`. You can set meta information in `./package.json` file.

Run: `gulp meta`

### Vendors

This task will copy vendor files to `./build/wp-content/themes/{custom-name}/vendors`.
Expand All @@ -96,18 +118,18 @@ Run: `gulp vendors`

---

## Scripts
## Scripts Task

This task will perform a series of sub-tasks to generate final JavaScript files.

* Select root files only from `./source/scripts`
* Include files
* Check for JavaScript style guide errors
* Check for JavaScript errors
* Add meta data banner
* Save unminified JavaScript file
* Minify JavaScript
* Save minified JavaScript file
* Check for style guide errors
* Check for errors
* Add meta information banner
* Save unminified file
* Minify and optimize
* Save minified file

*Note: Each file on the root of `./source/scripts` will be compiled to its own file in `./build/scripts`. Each file can have own includes, just like Sass with `@import` functionality. See `./source/scripts/main.js` as an example.*

Expand All @@ -119,21 +141,21 @@ Your JavaScript should adhere to most reasonable, yet opinionated, style guide.

---

## Styles
## Styles Task

This task will perform a series of sub-tasks to generate final CSS files.

* Select all files from `./source/styles`
* Check for Sass style guide errors
* Check for style guide errors
* Select root files only from `./source/styles`
* Compile Sass to CSS
* Add vendor prefixes
* Order CSS declarations
* Add meta data banner
* Save unminified CSS file
* Save unminified file
* Combine media queries
* Minify CSS
* Saved minified CSS file
* Minify and optimize
* Saved minified file

*Note: Each file on the root of `./source/styles` will be compiled to its own file in `./build/styles`.*

Expand All @@ -151,7 +173,7 @@ Your Sass should adhere to most reasonable, yet opinionated, style guide. If you

---

## Views
## Views Task

This task will copy PHP files.

Expand Down
38 changes: 28 additions & 10 deletions gulpfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,6 @@

'use strict';

// Constants
var THEME_NAME = "custom-theme";

// Dependencies
var gulp = require('gulp');
var plumber = require('gulp-plumber');
Expand All @@ -28,14 +25,27 @@ var minifyCss = require('gulp-minify-css');
var include = require('gulp-include');
var rename = require('gulp-rename');
var header = require('gulp-header');
var moment = require('moment');
var jscs = require('gulp-jscs');
var jshint = require('gulp-jshint');
var stylish = require('jshint-stylish');
var uglify = require('gulp-uglify');
var jshintConfig = require('./_js-lint.json');
var pkg = require('./package.json');
var banner = '/*! <%= pkg.title %> | <%= moment().format("MMMM Do YYYY, h:mm:ss A") %> */\n';
var banner = [
'/**',
' * Theme Name: <%= pkg.title %>',
' * Theme URI: <%= pkg.homepage %>',
' * Author: <%= pkg.author.name %>',
' * Author URI: <%= pkg.author.url %>',
' * Description: <%= pkg.description %>',
' * Version: <%= pkg.version %>',
' * License: <%= pkg.license %>',
' */',
'\n'
].join('\n');

// Constants
var THEME_NAME = pkg.name;

/**
* Error handling
Expand Down Expand Up @@ -131,6 +141,7 @@ gulp.task('assets', function(cb) {
[ 'images' ],
[ 'media' ],
[ 'misc' ],
[ 'meta' ],
[ 'vendors' ],
cb
);
Expand All @@ -155,7 +166,7 @@ gulp.task('images', function () {
.src('./source/images/**/*')
.pipe(changed('./build/wp-content/themes/' + THEME_NAME + '/images'))
.pipe(imagemin({
optimizationLevel: 4,
optimizationLevel: 3,
progressive: true,
svgoPlugins: [{
removeViewBox: false
Expand All @@ -178,6 +189,15 @@ gulp.task('misc', function() {
.pipe(gulp.dest('./build/wp-content/themes/' + THEME_NAME));
});

gulp.task('meta', function() {
return gulp
.src('./build/wp-content/themes/' + THEME_NAME + '/style.css')
.pipe(header(banner, {
pkg: pkg
}))
.pipe(gulp.dest('./build/wp-content/themes/' + THEME_NAME));
});

gulp.task('vendors', function() {
return gulp
.src('./source/vendors/**/*')
Expand All @@ -200,8 +220,7 @@ gulp.task('scripts', function() {
.pipe(jshint(jshintConfig))
.pipe(jshint.reporter(stylish))
.pipe(header(banner, {
pkg: pkg,
moment: moment
pkg: pkg
}))
.pipe(gulp.dest('./build/wp-content/themes/' + THEME_NAME + '/scripts'))
.pipe(uglify({
Expand Down Expand Up @@ -247,8 +266,7 @@ gulp.task('styles-build', function() {
configPath: './_css-comb.json'
}))
.pipe(header(banner, {
pkg: pkg,
moment: moment
pkg: pkg
}))
.pipe(gulp.dest('./build/wp-content/themes/' + THEME_NAME + '/styles'))
.pipe(combineMq())
Expand Down
18 changes: 9 additions & 9 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,17 +1,18 @@
{
"name": "gulp-wordpress-theme",
"title": "Gulp WordPress Theme",
"description": "Gulp WordPress Theme",
"version": "0.0.1",
"homepage": "http://www.domain.com",
"name": "wordpress-theme-name",
"title": "WordPress Theme Name",
"description": "WordPress Theme Description",
"version": "1.0.0",
"homepage": "http://www.theme-url.com",
"author": {
"name": "Author",
"url": "http://www.domain.com"
"name": "Author Name",
"url": "http://www.author-url.com"
},
"repository": {
"type": "git",
"url": "git@bitbucket.org:USER/REPOSITORY.git"
"url": "git@github.com:USER/REPOSITORY.git"
},
"license": "MIT",
"devDependencies": {
"browser-sync": "*",
"del": "*",
Expand All @@ -36,7 +37,6 @@
"gulp-util": "*",
"gulp-watch": "*",
"jshint-stylish": "*",
"moment": "*",
"require-dir": "*",
"run-sequence": "*"
}
Expand Down
7 changes: 0 additions & 7 deletions source/misc/style.css
Original file line number Diff line number Diff line change
@@ -1,7 +0,0 @@
/*
Theme Name: {theme-name}
Author: Author
Author URI: http://domain.com/
Description: Gulp WordPress Theme
Version: 1.0
*/

0 comments on commit e4b42fb

Please sign in to comment.