Giter Site home page Giter Site logo

whatwedo / gulp-wp-theme Goto Github PK

View Code? Open in Web Editor NEW
67.0 6.0 15.0 1.27 MB

gulp build system for developing WordPress themes | UNMAINTAINED

License: Other

JavaScript 61.57% PHP 31.24% Makefile 5.93% CSS 1.25%
wordpress-boilerplate unmaintained

gulp-wp-theme's People

Contributors

andreaspizsa avatar aobyrne avatar greypants avatar pbun avatar pprince avatar renestalder avatar scottsilvi avatar solomonhawk avatar xarem avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

gulp-wp-theme's Issues

Theme rename task

Gulp task to rename the theme. User should input a slug and name.

  • Slug: used as names in package.json, bower.json and as theme folder name on output.
  • Name: Used in style.css as theme name, visible to WordPress Admins.

Very handy when starting a new project.

Watcher stops if Sass compile error occurs

The watcher stops all tasks when a Sass error occurs and have to be restarted.

Better error handling needed, so error shows in command but does not stop the other tasks.

Add Browsersync Refresh on WordPress save

Browsersync have got a new API since v2.6.0. It enables to inject custom reloading which makes it possible to reload on database changes.

/* PHP pseudo codez */
add_action( 'save_post', function() {
    http_get("http://localhost:3000/__browser_sync__?method=reload");
});

Handling update routine

For a final release of a version 1.0.0 we should consider adding a update routine.

We could send it to NPM and providing the hooks for extending and configuring or we have to add some other way to separate the core from additions and configuration.

Add core config

Add a core config to util which is loaded in any case with default configs. This solves the problem of missing configuration parameters on updates if the developer doesn't replace the development and production configs.

This enables to overwrite the util and tasks folders as long the developer only changes configs in the gulp folder. After overwrite, alls tasks still work and new tasks can grab their configs from the core configuration. This enables the developer then to add configurations of newly added tasks to his config.

Version 2

Notes and ideas for a more enhanced version

  • Replace Stylus with PostCSS & cssnext
  • Replace browserify with webpack and babel
  • Modularized folder structure
  • Yeoman generator

Replace Stylus with PostCSS & cssnext

Enables writing raw CSS with future proof rules, defined in the CSS3 and Selector Level 4 spec.

Enables writing Selector Level 4 standards
http://cssnext.io/

For example, generic imports with globbing
https://github.com/postcss/postcss-import#glob

Replace browserify with webpack and babel

Enables easier consumption of external packages. Future proof JavaScript by writing ES6 and ES7 standards and compile them to ES6 or ES5 with babel.

Modularized folder structure

Using SMACSS like folder structure not only with CSS. Put things together so it could be copied by folder and embedded in another application.

Yeoman generator

Create a yeoman generator for easier project initialisation.

Add Asset Versions with gulp-rev and rev-del

Generates assets with new file names on file changes.

Example:

return gulp.src(config.src)
    .pipe(plumber())
    .pipe(stylus(config.options))
    .pipe(gulp.dest(config.dest))
    .pipe(autoprefixer(require('../../config').autoprefixer))
    .pipe(rev())
    .pipe(gulp.dest(config.dest))
    .pipe(rev.manifest())
    .pipe(revDel({ dest: config.dest }))
    .pipe(gulp.dest(config.dest))
    .pipe(reload({
      stream: true
    }))
    .on('error', handleErrors);

Writes a rev-manifest. Example:

{
  "style.css": "style-cad83a5a.css"
}

Which can then be read by functions.php

function get_http_response_code($url) {
    $headers = get_headers($url);
    return substr($headers[0], 9, 3);
}

function theme_scripts() {
    $styles = get_stylesheet_uri();

    if(get_http_response_code(get_template_directory_uri().'/rev-manifest.json') == "200"){
        $assetManifest = file_get_contents(get_template_directory_uri().'/rev-manifest.json');
        $assets = json_decode($assetManifest, true);
        $styles = get_template_directory_uri() . '/' . $assets['style.css'];
    }

    // Bling bling you know
    wp_enqueue_style( 'farner-campaigning-styles', $styles);
}

Cannot find module package.json

i dont know this is error because my version or not, i use
node v4.2.1
npm 3.5.4

i use cygwin to test it
i have problem to start the script
Error: Cannot find module '/cygdrive/g/gulp/gulp-wp-theme/package.json'

i solve this by change var packageConfig = require(process.env.PWD + '/package.json');
to var packageConfig = require('../package.json');

in gulp config-development and config-production

i have question why not change it to
var packageConfig = require('../package.json');
i think its save for other operating system

Error: Cannot find module 'yargs'

Error: Cannot find module 'yargs'
    at Function.Module._resolveFilename (module.js:338:15)
    at Function.Module._load (module.js:280:25)
    at Module.require (module.js:364:17)
    at require (module.js:380:17)
    at Object.<anonymous> (/var/www/wordpress/wp-content/themes/gulp-wp-theme/gulp/config.js:14:12)
    at Module._compile (module.js:456:26)
    at Object.Module._extensions..js (module.js:474:10)
    at Module.load (module.js:356:32)
    at Function.Module._load (module.js:312:12)
    at Module.require (module.js:364:17)

Add clean task to remove files

By now, for example if you delete templates, they will not be deleted in the dev or productive theme folder.

Add a clean task to clean folders before build or compile and removing files of the specific watcher task on watch.

Note
gulp-clean should not be used since it may be black listed. You may use node fs.

How to enqueue or use jQuery with Browserify config

I'm new to Browserify, and trying to grok how you'd use jQuery in this theme, and not seeing it enqueue'd or anything in source, but do see the browserify-shim being declared, and kind of understand that. Do you typically enqueue the Google CDN version on entire WP site, or is there a different method of dependency management with Browserify that I'm not seeing?

Any change you could provide a quick example of how you'd use, say: jQuery MatchHeight in this theme with Browserify please?

Thanks for your time!

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.