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

Commit f6a3774

Browse files
committed
Merge branch 'develop'
* develop: Documentation update Proper cssnano integration Version bump and dependency update Deps update and version bump
2 parents 79e3fde + de05f8c commit f6a3774

File tree

6 files changed

+34
-36
lines changed

6 files changed

+34
-36
lines changed

gulpconfig.js

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -85,8 +85,12 @@ module.exports = {
8585
, dest: build
8686
}
8787
, compiler: 'libsass' // Choose a Sass compiler: 'libsass' or 'rubysass'
88-
, 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 :)
89-
, minify: { safe: true }
88+
, cssnano: {
89+
autoprefixer: {
90+
add: true
91+
, browsers: ['> 3%', 'last 2 versions', 'ie 9', 'ios 6', 'android 4'] // This tool is magic and you should use it in all your projects :)
92+
}
93+
}
9094
, rubySass: { // Requires the Ruby implementation of Sass; run `gem install sass` if you use this; Compass is *not* included by default
9195
loadPath: ['./src/scss', bower, modules] // Adds Bower and npm directories to the load path so you can @import directly
9296
, precision: 6

gulpfile.js/tasks/styles.js

Lines changed: 9 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -4,29 +4,25 @@ var gulp = require('gulp')
44
, gutil = require('gulp-util')
55
, plugins = require('gulp-load-plugins')({ camelize: true })
66
, config = require('../../gulpconfig').styles
7-
, autoprefixer = require('autoprefixer')
8-
, processors = [autoprefixer(config.autoprefixer)] // Add additional PostCSS plugins to this array as needed
97
;
108

11-
// Build stylesheets from source Sass files, autoprefix, and write source maps (for debugging) with rubySass
9+
// Build stylesheets from source Sass files, post-process, and write source maps (for debugging) with rubySass
1210
gulp.task('styles-rubysass', function() {
1311
return plugins.rubySass(config.build.src, config.rubySass)
1412
.on('error', gutil.log) // Log errors instead of killing the process
15-
.pipe(plugins.postcss(processors))
16-
.pipe(plugins.cssnano(config.minify))
17-
.pipe(plugins.sourcemaps.write('./')) // No need to init; this is set in the configuration
18-
.pipe(gulp.dest(config.build.dest)); // Drops the unminified CSS file into the `build` folder
13+
.pipe(plugins.cssnano(config.cssnano)) // Post-process CSS (minify, autoprefix, etc.)
14+
.pipe(plugins.sourcemaps.write('./')) // Write an external sourcemap; no need to initialize with rubysass as this is already done in the configuration
15+
.pipe(gulp.dest(config.build.dest)); // Render the final CSS file(s) into the `build` folder
1916
});
2017

21-
// Build stylesheets from source Sass files, autoprefix, and write source maps (for debugging) with libsass
18+
// Build stylesheets from source Sass files, post-process, and write source maps (for debugging) with libsass
2219
gulp.task('styles-libsass', function() {
2320
return gulp.src(config.build.src)
24-
.pipe(plugins.sourcemaps.init())
21+
.pipe(plugins.sourcemaps.init()) // Note that sourcemaps need to be initialized with libsass
2522
.pipe(plugins.sass(config.libsass))
26-
.pipe(plugins.postcss(processors))
27-
.pipe(plugins.cssnano(config.minify))
28-
.pipe(plugins.sourcemaps.write('./')) // Writes an external sourcemap
29-
.pipe(gulp.dest(config.build.dest)); // Drops the unminified CSS file into the `build` folder
23+
.pipe(plugins.cssnano(config.cssnano))
24+
.pipe(plugins.sourcemaps.write('./'))
25+
.pipe(gulp.dest(config.build.dest));
3026
});
3127

3228
// Easily configure the Sass compiler from `/gulpconfig.js`

package.json

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "wordpress-gulp-starter-kit",
3-
"version": "0.2.3",
3+
"version": "0.2.5",
44
"description": "A starter kit for developing WordPress themes with Gulp",
55
"homepage": "https://github.com/synapticism/wordpress-gulp-starter-kit",
66
"repository": {
@@ -25,21 +25,19 @@
2525
"main": "gulpfile.js",
2626
"private": true,
2727
"devDependencies": {
28-
"autoprefixer": "^6.3.6",
29-
"browser-sync": "^2.12.3",
28+
"browser-sync": "^2.13.0",
3029
"del": "^2.2.0",
3130
"gulp": "^3.9.1",
3231
"gulp-changed": "^1.3.0",
3332
"gulp-concat": "^2.6.0",
34-
"gulp-cssnano": "^2.1.1",
35-
"gulp-imagemin": "^2.4.0",
36-
"gulp-jshint": "^2.0.0",
33+
"gulp-cssnano": "^2.1.2",
34+
"gulp-imagemin": "^3.0.1",
35+
"gulp-jshint": "^2.0.1",
3736
"gulp-livereload": "^3.8.1",
38-
"gulp-load-plugins": "^1.2.2",
39-
"gulp-postcss": "^6.1.0",
37+
"gulp-load-plugins": "^1.2.4",
4038
"gulp-rename": "^1.2.2",
4139
"gulp-ruby-sass": "^2.0.6",
42-
"gulp-sass": "^2.2.0",
40+
"gulp-sass": "^2.3.1",
4341
"gulp-sourcemaps": "^1.6.0",
4442
"gulp-uglify": "^1.5.3",
4543
"gulp-util": "^3.0.7",

readme.md

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ Why use this project instead of any of the alternatives? A few advantages:
1010
* You should be able to easily drop your own theme into the `src` folder and start hacking without much additional setup.
1111
* Documentation and comments in the code assume a novice level of understanding.
1212
* Builds on existing WordPress and Gulp best practices without doing anything too crazy.
13+
* Includes several JS and Sass integrations to show you some of the possibilities. All of these are easily removed.
1314
* This kind of workflow will save you a ton of time and help you make better, more readily-optimized themes once you learn how it all works.
1415

1516

@@ -36,7 +37,7 @@ If you're already up and running with most of the usual Node ecosystem tools thi
3637
## SETUP
3738

3839
* 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.
39-
* 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/)).
40+
* 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/)). You may see warnings about deprecated packages and what-not; that's probably fine, just keep going!
4041
* [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.
4142
* [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.
4243
* This build process assumes you're up and running with [source maps for both JavaScript and Sass](http://blog.teamtreehouse.com/introduction-source-maps). You may need to configure your browser or debugging environment to make sense of the minified files generated by Gulp!
@@ -48,7 +49,7 @@ If you're already up and running with most of the usual Node ecosystem tools thi
4849

4950
Previously this project shipped without a working theme included. I figured that with all the great starter themes out there (for instance, [_s](https://github.com/Automattic/_s), [Roots](https://github.com/roots/roots), and [Bones](https://github.com/eddiemachado/bones)) it wouldn't be hard to drop one in and start theming. I don't personally use any of these so I was a little surprised to discover how tricky this can be. Starter themes, despite their "bare bones" reputation, are often bulky and opinionated. Some even ship with their own build processes already in place!
5051

51-
It seems there is a need for what I'd call a *minimum viable theme*: a truly bare bones WordPress starter theme featuring only the essentials to get up and running, something that you can assess at a glance. For the purposes of this project I have created such a theme, tentatively named `voidx`. It isn't pretty and isn't up to [WordPress standards](https://wordpress.org/plugins/theme-check/) but it works well enough to show off some of the power of this workflow. Feel free to play with or discard it as you wish. All files under `src` can be replaced by your own files, you just have to be sure to wire things up properly in the `gulpconfig.js` file if you swap in your own stuff. I've already integrated [timeago](http://timeago.yarp.com/), a simple script to transform timestamps into something more human-readable, but this is easily removed if you don't like it (which is sort of the point of having such scaffolding, so you can easily swap stuff in and out).
52+
It seems there is a need for what I'd call a *minimum viable theme*: a truly bare bones WordPress starter theme featuring only the essentials to get up and running, something that you can assess at a glance. For the purposes of this project I have created such a theme, tentatively named `voidx`. It isn't pretty and isn't up to [WordPress standards](https://wordpress.org/plugins/theme-check/) but it works well enough to show off some of the power of this workflow. Feel free to play with or discard it as you wish. All files under `src` can be replaced by your own files, you just have to be sure to wire things up properly in the `gulpconfig.js` file if you swap in your own stuff. Several scripts have already been integrated to show you how it's done, but these are easily if you don't like 'em (which is sort of the point of having such scaffolding, so you can easily swap stuff in and out).
5253

5354
There are two components worth a closer look:
5455

@@ -84,7 +85,7 @@ Configuration is handled by a single file: `gulpconfig.js`. If you leave the dir
8485
* [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 ;)
8586
* Script settings: draw your attention to `scripts.bundles` and `scripts.chunks`. This feature is essentially a poor man's [Browserify](http://browserify.org/) or [Webpack](https://webpack.github.io/). By defining different "chunks" (script files that combine to provide a particular feature) and "bundles" (chunks that combine to provide feature sets) you can generate an assortment of files that can be efficiently and intelligently loaded through your WordPress theme. This approach has its limitations, of course, particularly when dependencies are shared between scripts, but it should be of use to many WordPress theme developers.
8687

87-
Interested in adding new Gulp plugins to your build system? A full tutorial is out of scope for this project but it really shouldn't be all that hard to figure out. In brief, install a plugin with `npm install [package] --save-dev`, require it in a suitable task file, add something to the configuration file if needed, and drop it into the pipeline somewhere. Some types of plugin are particularly easy to add, for instance anything listed on the [postcss.parts](http://postcss.parts/) web site (install, require, and add to the `processor` variable in `/gulpfile.js/tasks/styles.js`).
88+
Interested in adding new Gulp plugins to your build system? A full tutorial is out of scope for this project but it really shouldn't be all that hard to figure out. In brief, install a plugin with `npm install [package] --save-dev`, require it in a suitable task file, add something to the configuration file if needed, and drop it into the pipeline somewhere. Some types of plugin are particularly easy to add, for instance anything listed on the [postcss.parts](http://postcss.parts/) web site once you have [gulp-postcss](https://github.com/postcss/gulp-postcss) installed and configured in `/gulpfile.js/tasks/styles.js`.
8889

8990

9091

@@ -111,13 +112,12 @@ A few handy tips from the [Bower documentation](https://bower.io):
111112

112113
## WORKING WITH SASS
113114

114-
* 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/).
115+
* This project 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 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/).
115116
* [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`.
117+
* Stylesheets are post-processed with [cssnano](http://cssnano.co/), a [PostCSS](https://github.com/postcss/postcss) plugin with [Autoprefixer](https://github.com/ai/autoprefixer) baked in, eliminating the need for vendor prefixes.
118+
* [Sourcemaps](http://www.html5rocks.com/en/tutorials/developertools/sourcemaps/) are generated by [gulp-sourcemaps](https://github.com/floridoo/gulp-sourcemaps) to make debugging stylesheets a snap. Note: all generated CSS is production-ready (*e.g.* minified and prefixed); sourcemaps only appear in the `build` directory.
116119
* Packages installed with Bower or npm are in the path by default so you can `@import` Sass files directly, as seen in `style.scss`.
117-
* The `build` folder is provisioned with regular versions of all stylesheets but `dist` only contains minified versions for production.
118-
* 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).
119-
* 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.
120-
* [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.
120+
* 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) and [Scut](https://davidtheclark.github.io/scut/), a minimalist library of useful Sass mixins and functions for the post-vendor prefixing era. Both of these are easy to remove if you're not interested in them.
121121

122122

123123

@@ -149,7 +149,7 @@ Let's say you run across a cool project like [Headroom.js](http://wicky.nillia.m
149149
* Create an additional script at `src/js/headroom.js` to invoke the main script:
150150

151151
```language-javascript
152-
// Invoke Headroom.js
152+
// Invoke Headroom.js; the outer function is is an IIFE, the inner one is a shortcut to document.ready
153153
;(function($){
154154
$(function(){
155155
$("#wrap-header").headroom({ offset: 60 });

src/inc/assets.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,8 +57,8 @@ function voidx_enqueue_scripts() {
5757
if ( !empty( $script_vars ) )
5858
wp_localize_script( $script_handle, 'voidxVars', $script_vars );
5959

60-
// Script variables specific to WP AJAX Page Loader (these are separate from the main theme script variables due to the naming requirement; the object must be `PG8Data`)
61-
// This appears and NOT in the conditional block (above) because these variables will be attached to the main script handle (which may be modified after the page loader block)
60+
// Script variables specific to WP AJAX Page Loader (these are separate from the main theme script variables due to the naming requirement; the object *must* be `PG8Data`)
61+
// This appears here and NOT in the conditional block (above) because these variables will be attached to the main script handle (which may be modified after the page loader block)
6262
if ( !empty( $script_vars_page_loader ) )
6363
wp_localize_script( $script_handle, 'PG8Data', $script_vars_page_loader );
6464

src/scss/_config.scss

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ $_metadata: (
3030
, theme-author: "Alexander Synaptic"
3131
, theme-author-uri: "http://synapticism.com"
3232
, theme-description: "A minimally viable theme made with the WordPress/Gulp starter kit"
33-
, theme-version: "0.2.3"
33+
, theme-version: "0.2.5"
3434
, theme-license: "GPLv3"
3535
, theme-license-uri: "http://www.gnu.org/licenses/gpl.txt"
3636
, theme-tags: (light, responsive-layout, right-sidebar, starter-theme, two-columns, translation-ready, white)

0 commit comments

Comments
 (0)