Skip to content
This repository was archived by the owner on Sep 3, 2024. It is now read-only.

Commit a2f6800

Browse files
committed
Merge branch 'develop'
* develop: Version bump Further reduction of Bower imprint Dependency update and version bump Documentation update Removing unnecessary HTML markup Reducing Bower footprint in favour of npm Small dependency update Clarifying script integration and asset loading Dependency update (minor)
2 parents fc82b90 + 44b2c76 commit a2f6800

File tree

15 files changed

+72
-91
lines changed

15 files changed

+72
-91
lines changed

.bowerrc

Lines changed: 0 additions & 6 deletions
This file was deleted.

bower.json

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -27,10 +27,5 @@
2727
"tests",
2828
".sass-cache",
2929
"build"
30-
],
31-
"devDependencies": {
32-
"meyer-reset": "*",
33-
"normalize.css": "^3.0.3",
34-
"scut": "^1.2.1"
35-
}
30+
]
3631
}

gulpconfig.js

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -14,14 +14,6 @@ var project = 'voidx' // The directory name for your theme;
1414
// Project settings
1515
module.exports = {
1616

17-
bower: {
18-
normalize: { // Copies `normalize.css` from `bower_components` to `src/scss` and renames it to allow for it to imported as a Sass file
19-
src: bower+'normalize.css/normalize.css'
20-
, dest: src+'scss'
21-
, rename: '_normalize.scss'
22-
}
23-
},
24-
2517
browsersync: {
2618
files: [build+'/**', '!'+build+'/**.map'] // Exclude map files
2719
, notify: false // In-line notifications (the blocks of text saying whether you are connected to the BrowserSync server or not)
@@ -56,14 +48,17 @@ module.exports = {
5648
scripts: {
5749
bundles: { // Bundles are defined by a name and an array of chunks (below) to concatenate; warning: this method offers no dependency management!
5850
core: ['core']
59-
, pg8: ['pg8', 'core']
51+
, pageloader: ['pageloader', 'core']
6052
}
6153
, chunks: { // Chunks are arrays of paths or globs matching a set of source files; this way you can organize a bunch of scripts that go together into pieces that can then be bundled (above)
54+
// The core chunk is loaded no matter what; put essential scripts that you want loaded by your theme in here
6255
core: [
6356
src+'js/responsive-menu.js'
6457
, src+'js/core.js'
6558
]
66-
, pg8: [
59+
// The pageloader chunk provides an example of how you would add a user-configurable feature to your theme; you can delete this if you wish
60+
// Have a look at the `src/inc/assets.php` to see how script bundles could be conditionally loaded by a theme
61+
, pageloader: [
6762
modules+'html5-history-api/history.js' // The modules directory contains packages downloaded via npm
6863
, modules+'spin.js/spin.js'
6964
, modules+'spin.js/jquery.spin.js'
@@ -97,12 +92,12 @@ module.exports = {
9792
, autoprefixer: { browsers: ['> 3%', 'last 2 versions', 'ie 9', 'ios 6', 'android 4'] } // This tool is magic and you should use it in all your projects :)
9893
, minify: { keepSpecialComments: 1, roundingPrecision: 4 } // Keep special comments preserves the bits we need for WordPress to recognize the theme's stylesheet
9994
, rubySass: { // Requires the Ruby implementation of Sass; run `gem install sass` if you use this; Compass is *not* included by default
100-
loadPath: ['./src/scss', bower] // Adds the `bower_components` directory to the load path so you can @import directly
95+
loadPath: ['./src/scss', bower, modules] // Adds Bower and npm directories to the load path so you can @import directly
10196
, precision: 6
10297
, sourcemap: true
10398
}
10499
, libsass: { // Requires the libsass implementation of Sass (included in this package)
105-
includePaths: ['./src/scss', bower] // Adds the `bower_components` directory to the load path so you can @import directly
100+
includePaths: ['./src/scss', bower, modules] // Adds Bower and npm directories to the load path so you can @import directly
106101
, precision: 6
107102
, onError: function(err) {
108103
return console.log(err);
@@ -128,6 +123,11 @@ module.exports = {
128123
src: [build+'**/*', '!'+build+'**/*.map']
129124
, dest: dist
130125
}
126+
, normalize: { // Copies `normalize.css` from `node_modules` to `src/scss` and renames it to allow for it to imported as a Sass file
127+
src: modules+'normalize.css/normalize.css'
128+
, dest: src+'scss'
129+
, rename: '_normalize.scss'
130+
}
131131
},
132132

133133
watch: { // What to watch before triggering each specified task; if files matching the patterns below change it will trigger BrowserSync or Livereload

gulpfile.js/tasks/bower.js

Lines changed: 0 additions & 17 deletions
This file was deleted.

gulpfile.js/tasks/main.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,9 @@ var gulp = require('gulp');
55
// Default task chain: build -> (livereload or browsersync) -> watch
66
gulp.task('default', ['watch']);
77

8+
// One-off setup tasks
9+
gulp.task('setup', ['utils-normalize']);
10+
811
// Build a working copy of the theme
912
gulp.task('build', ['images', 'scripts', 'styles', 'theme']);
1013

gulpfile.js/tasks/utils.js

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,16 @@ var gulp = require('gulp')
66
, config = require('../../gulpconfig').utils
77
;
88

9+
// Used to get around Sass's inability to properly @import vanilla CSS; see: https://github.com/sass/sass/issues/556
10+
gulp.task('utils-normalize', function() {
11+
return gulp.src(config.normalize.src)
12+
.pipe(plugins.changed(config.normalize.dest))
13+
.pipe(plugins.rename(config.normalize.rename))
14+
.pipe(gulp.dest(config.normalize.dest));
15+
});
16+
917
// Totally wipe the contents of the `dist` folder to prepare for a clean build; additionally trigger Bower-related tasks to ensure we have the latest source files
10-
gulp.task('utils-wipe', ['bower'], function() {
18+
gulp.task('utils-wipe', ['setup'], function() {
1119
return del(config.wipe);
1220
});
1321

package.json

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "wordpress-gulp-starter-kit",
3-
"version": "0.1.1",
3+
"version": "0.2.0",
44
"description": "A starter kit for developing WordPress themes with Gulp",
55
"homepage": "https://github.com/synapticism/wordpress-gulp-starter-kit",
66
"repository": {
@@ -20,36 +20,38 @@
2020
"browsersync",
2121
"livereload"
2222
],
23-
"scripts": {
24-
"postinstall": "bower install"
25-
},
2623
"author": "Alexander Synaptic <[email protected]>",
2724
"license": "GPL-3.0",
2825
"main": "gulpfile.js",
2926
"private": true,
3027
"devDependencies": {
31-
"autoprefixer": "^6.1.0",
32-
"browser-sync": "^2.9.12",
33-
"del": "^2.0.2",
28+
"autoprefixer": "^6.1.1",
29+
"browser-sync": "^2.10.0",
30+
"del": "^2.1.0",
3431
"gulp": "^3.9.0",
3532
"gulp-changed": "^1.3.0",
3633
"gulp-concat": "^2.6.0",
3734
"gulp-imagemin": "^2.4.0",
38-
"gulp-jshint": "^1.12.0",
35+
"gulp-jshint": "^2.0.0",
3936
"gulp-livereload": "^3.8.1",
4037
"gulp-load-plugins": "^1.1.0",
4138
"gulp-minify-css": "^1.2.1",
4239
"gulp-postcss": "^6.0.1",
4340
"gulp-rename": "^1.2.2",
44-
"gulp-ruby-sass": "^2.0.5",
41+
"gulp-ruby-sass": "^2.0.6",
4542
"gulp-sass": "^2.1.0",
4643
"gulp-sourcemaps": "^1.6.0",
47-
"gulp-uglify": "^1.4.2",
44+
"gulp-uglify": "^1.5.1",
4845
"gulp-util": "^3.0.7",
4946
"html5-history-api": "^4.2.4",
5047
"merge-stream": "^1.0.0",
48+
"normalize.css": "^3.0.3",
5149
"require-dir": "^0.3.0",
50+
"scut": "^1.3.0",
5251
"spin.js": "^2.3.2",
5352
"wp-ajax-page-loader": "^0.2.0"
53+
},
54+
"scripts": {
55+
"postinstall": "gulp setup"
5456
}
5557
}

readme.md

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# A WORDPRESS/GULP STARTER KIT
22

3-
Designing WordPress themes the old-fashioned way is time-consuming and error-prone. Automating the build process allows us to integrate best practices into our workflow while saving time. This project is a *starter kit* for developing highly optimized WordPress themes with [Gulp](http://gulpjs.com/), [npm](https://www.npmjs.com/), [Bower](http://bower.io/), and [Sass](http://sass-lang.com/), among other tools. This is *not* meant to be a starter theme or framework (although I have included a *minimum viable theme* to demonstrate some of the possibilities). It is, instead, a kind of *project scaffolding* and *example workflow* for modern and efficient WordPress theme development.
3+
Designing WordPress themes the old-fashioned way is time-consuming and error-prone. Automating the build process allows us to integrate best practices into our workflow while saving time. This project is a *starter kit* for developing highly optimized WordPress themes with [Gulp](http://gulpjs.com/), [npm](https://www.npmjs.com/), and [Sass](http://sass-lang.com/), among other tools. This is *not* meant to be a starter theme or framework (although I have included a *minimum viable theme* to demonstrate some of the possibilities). It is, instead, a kind of *project scaffolding* and *example workflow* for modern and efficient WordPress theme development.
44

55
The latest version of this starter kit features a modular Gulp file design inspired by Dan Tello's excellent [gulp-starter](https://github.com/greypants/gulp-starter). Configuration is isolated from the tasks themselves to make it easier to change paths and modify settings. This approach is slightly more complicated than what I originally [outlined on my blog](http://synapticism.com/dev/wordpress-theme-development-with-gulp-bower-and-sass/) but also far more powerful. Live local development is now facilitated by your choice of [BrowserSync](http://www.browsersync.io/) or [LiveReload](http://livereload.com/) (the default choice).
66

@@ -36,7 +36,6 @@ If you're already up and running with most of the usual Node ecosystem tools thi
3636

3737
* Edit `gulpconfig.js` and, *at the very least*, change the `project` variable to match the name of your theme. If you like the way this workflow is setup you shouldn't need to edit any of the files under `gulpfile.js/tasks` just yet.
3838
* Install all dependencies by running `npm install`. This will fetch all dependencies listed in `package.json` (which includes front-end JavaScript packages and back-end tools like Gulp plugins and [BrowserSync](http://www.browsersync.io/)).
39-
* The previous command will also invoke `bower install` (assuming you have Bower installed) and will fetch all dependencies listed in `bower.json` (which includes front-end dependencies e.g. jQuery plugins, Sass frameworks, icon libraries, and so on).
4039
* [BrowserSync](http://www.browsersync.io/) setup: assuming you have a local development environment setup all you should need to do is enter the URL into the `proxy` setting in `gulpconfig.js`. Why use BrowserSync? It's fast, awesome, and allows for simultaneous responsive development across multiple devices.
4140
* [LiveReload](http://livereload.com/) setup: install a browser extension for [Chrome](https://chrome.google.com/webstore/detail/livereload/jnihajbhpnppcggbcgedagnkighmdlei) or Firefox. Why use LiveReload? It does the job without complications or additional setup after the extension is installed.
4241
* Run `gulp` and start hacking!
@@ -76,6 +75,8 @@ Note: both the `build` and `dist` directories are disposable and can be regenera
7675

7776
To get started try running `gulp` from the command line. This fires `gulpfile.js/index.js` and should build a working copy of the included theme. The other command you will use from time to time is `gulp dist`, which builds a distribution copy.
7877

78+
You might also find a need for `gulp setup` which runs one-off setup tasks (which is also triggered by `gulp dist`). In the default installation this setup task only copies `normalize.css` to `src/scss` so it can be imported like a native SCSS file. This task is also run after `npm install` completes.
79+
7980
Configuration is handled by a single file: `gulpconfig.js`. If you leave the directory structure intact there won't be too much that needs changing here but I can think of two non-obvious components you might want to modify or at least look at:
8081

8182
* [BrowserSync](http://www.browsersync.io/) settings: if you are developing on a local web server you will want to enter the URL into `browsersync.proxy` and then change `watch.watcher` to `browsersync` to take it for a test drive. You'll know it's working when you run `gulp` and a new browser opens with a live copy of your web site. Make changes to any of the Sass files and they should be shown on the page almost immediately. Of course, BrowserSync really shines when you connect a mobile device to your development server, but for that you're on your own ;)
@@ -87,11 +88,11 @@ Interested in adding new Gulp plugins to your build system? A full tutorial is o
8788

8889
## WORKING WITH NPM
8990

90-
[npm](https://www.npmjs.com/) is great for working with JavaScript-based packages of all kinds (front-end or back-end). Previously this starter kit emphasized the use of Bower to retrieve and manage front-end dependencies but nowadays my personal preference is to use npm, mostly because it's way easier to update dependencies than Bower using tools like [npm-check-updates](https://www.npmjs.com/package/npm-check-updates).
91+
[npm](https://www.npmjs.com/) is great for working with packages of all kinds (front-end or back-end) and is increasingly becoming the package manager of choice. Previously this starter kit emphasized the use of Bower to retrieve and manage front-end dependencies but nowadays my personal preference is to use npm, mostly because it's way easier to update dependencies than Bower using tools like [npm-check-updates](https://www.npmjs.com/package/npm-check-updates).
9192

9293
* Find new packages with `npm search [package]`.
9394
* Install new packages with: `npm install [package] --save-dev`.
94-
* A general rule-of-thumb: if it's mostly JavaScript-based and you can find it there just use npm.
95+
* A general rule-of-thumb: if you can find it there just use npm.
9596

9697

9798

@@ -110,9 +111,9 @@ A few handy tips from the [Bower documentation](https://bower.io):
110111

111112
* This package now supports either [gulp-ruby-sass](https://github.com/sindresorhus/gulp-ruby-sass/) (which requires [the original Ruby implementation of Sass](https://github.com/sass/sass)) or [gulp-sass](https://www.npmjs.org/package/gulp-sass) (based on the newer, experimental, and faster [libsass](https://github.com/sass/libsass), now active by default). Switch `styles.compiler` in the configuration file as needed! For reference: [Sass compatibility table](https://sass-compatibility.github.io/).
112113
* [Sass](http://sass-lang.com/) files can be found in `/src/scss`. Gulp will not process Sass partials beginning with `_`; these need to be explicitly imported (see `style.scss` for an example). On the other hand, if you want to output any other CSS files just drop the underscore *e.g.* `editor-style.scss`.
113-
* Bower components are in the path by default so you can `@import` Sass files directly, as seen in `_loader.scss` and `_reset.scss`.
114+
* Packages installed with Bower or npm are in the path by default so you can `@import` Sass files directly, as seen in `style.scss`.
114115
* The `build` folder is provisioned with regular versions of all stylesheets but `dist` only contains minified versions for production.
115-
* This starter kit ships with [Normalize.css](https://necolas.github.io/normalize.css/) (active by default) and [Eric Meyer's reset](http://meyerweb.com/eric/tools/css/reset/) (inactive by default).
116+
* This starter kit ships with [Normalize.css](https://necolas.github.io/normalize.css/) (imported into the `src/scss` directory using `gulp setup`; you might also like to explore the use of [normalize-scss](https://github.com/JohnAlbin/normalize-scss) for your project).
116117
* Compass is *not* included as [Autoprefixer](https://github.com/ai/autoprefixer), a [PostCSS](https://github.com/postcss/postcss) plugin, eliminates the need for vendor prefixing (which is what most Sass frameworks focus on these days). Instead I have included [Scut](https://davidtheclark.github.io/scut/), a minimalist library of useful Sass mixins and functions for the post-vendor prefixing era. This is easily removed if you're not interested in using it.
117118
* [Sourcemaps](http://www.html5rocks.com/en/tutorials/developertools/sourcemaps/?redirect_from_locale=tw) are generated by [gulp-sourcemaps](https://github.com/floridoo/gulp-sourcemaps) to make debugging stylesheets a snap.
118119

@@ -160,9 +161,9 @@ That's all there is to it. Now this script can be switched on or off in two conf
160161

161162
Things can and will go wrong when working with new tools but there are a few simple things you can do to avoid the worst of it:
162163

163-
* Make sure all your base software is up to date, particularly npm, node, Bower, etc.
164+
* Make sure everything is up to date, particularly this package, npm, node, Bower, etc.
164165
* If you're getting weird errors you can't figure out try deleting `node_modules` and running `npm install`.
165-
* You might also have some luck cleaning the cache for both npm and Bower, both of which respond to the `clean cache` command.
166+
* You might also have some luck cleaning the cache for both npm and Bower, both of which respond to the `clean cache` command, or try `npm prune && npm install`.
166167

167168

168169

@@ -173,7 +174,6 @@ Things can and will go wrong when working with new tools but there are a few sim
173174
* [Reduce unnecessary wrapper plugins](https://github.com/sogko/gulp-recipes/tree/master/unnecessary-wrapper-gulp-plugins).
174175
* RTL support with [gulp-rtlcss](https://github.com/jjlharrison/gulp-rtlcss)?
175176
* Explore using Gulp for I18n (a quick scan revealed nothing obviously useful).
176-
* Add an example using Bower.
177177
* Browserify integration? The existing bundles/chunks system is very DIY and non-standard. Feedback welcome.
178178
* More good ideas from [Gulp recipes](https://github.com/gulpjs/gulp/tree/master/docs/recipes).
179179

src/footer.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
</div>
22
<div id="wrap-footer" class="wrap-footer">
3-
<footer id="colophon" class="site-footer" role="contentinfo">
4-
<nav id="site-footer-navigation" role="navigation">
3+
<footer id="colophon" class="site-footer">
4+
<nav id="site-footer-navigation">
55
<?php wp_nav_menu( array( 'theme_location' => 'footer', 'menu_id' => 'menu-footer', 'menu_class' => 'menu-inline' ) ); ?>
66
</nav>
77
</footer>

src/header.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<!DOCTYPE html>
22
<html <?php language_attributes(); ?>>
33
<head>
4-
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" />
4+
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
55
<meta charset="<?php bloginfo( 'charset' ); ?>" />
66
<meta name="viewport" content="width=device-width, initial-scale=1" />
77
<title><?php wp_title( '-', true, 'right' ); ?></title>
@@ -12,13 +12,13 @@
1212
<body <?php body_class(); ?>>
1313
<div id="page" class="hfeed site">
1414
<div id="wrap-header" class="wrap-header">
15-
<header id="masthead" class="site-header" role="banner">
15+
<header id="masthead" class="site-header">
1616
<div class="site-branding">
1717
<h1 class="site-title"><a href="<?php echo esc_url( home_url( '/' ) ); ?>" rel="home"><?php bloginfo( 'name' ); ?></a></h1>
1818
<h2 class="site-description"><?php bloginfo( 'description' ); ?></h2>
1919
</div>
20-
<nav id="site-navigation" class="site-navigation" role="navigation">
21-
<button id="responsive-menu-toggle" role="button"><?php _e( 'Menu', 'voidx' ); ?></button>
20+
<nav id="site-navigation" class="site-navigation">
21+
<button id="responsive-menu-toggle"><?php _e( 'Menu', 'voidx' ); ?></button>
2222
<div id="responsive-menu"><?php wp_nav_menu( array( 'theme_location' => 'header', 'menu_id' => 'menu-header', 'menu_class' => 'menu-inline' ) ); ?></div>
2323
</nav>
2424
</header>

0 commit comments

Comments
 (0)