npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@mepheser/wordpress-gulp

v1.2.0

Published

Gulp build for sane wordpress theme development

Downloads

77

Readme

Gulp build for wordpress theme development

Opinionated build using convention over configuration. Provides pipelines for styles (scss to css) and javascript (typescript to es5) and hot reloading. Expects a specific source directory layout and provides common tasks:

  • gulp wp-build
    • Create distributable theme in public folder
    • Process scss files to css
    • Process typescript files to plain js
    • Set theme version in style.css to current git hash
  • gulp wp-build:watch for development
    • Execute wp-build in watch mode for live development
    • Set up browsersync for hot reloading
    • Back copy acf-json from public to src when edited in browser
  • gulp wp-release
    • Prompt for semver bump (major|minor|patch)
    • Bump version in package.json
    • Create and push git tag release/

Installation

Add dependencies

Create a npm/yarn project and add the following dev dependencies:

  • @mepheser/wordpress-gulp
  • gulp
  • typescript

Add wordpress gulp tasks to local gulp file

Create a simple gulpfile.js and add wordpress tasks by passing gulp object to init function:

var gulp = require('gulp');
var wordpressGulp = require('@mepheser/wordpress-gulp')

wordpressGulp(gulp)

After that, wp-build, wp-build:watch and wp-release are available in local build.

Directory layout and processing

All different source file types are located in subdirectories of src and are compiled/copied to public. A simple theme output folder may look like

Example

Input: separated by file type to be processed differently

src/
├── fonts
│   ├── roboto.woff
├── images
│   ├── logo.jpg
├── php
│   ├── acf-json
│   │   ├── group_5bc065b43c546.json
│   ├── templates
│   │   ├── even-more-template-files.php
│   ├── 404.php
│   ├── functions.php
│   ├── index.php
│   └── style.css
├── scripts
│   └── some-internal-component.ts
│   └── main.ts
└── styles
    ├── _colors.scss
    ├── _more-internal-partials.scss    
    └── main.scss

Output: a wordpress ready theme directory

public/
├── acf-json
│   ├── group_5bc065b43c546.json
├── assets
│   ├── fonts
│   │   ├── roboto.woff
│   ├── images
│   │   ├── logo.jpg
│   ├── scripts
│   │   └── bundle.js
│   └── styles
│       └── main.css
├── templates
│   ├── even-more-template-files.php
├── 404.php
├── functions.php
├── index.php
└── style.css

Details by file type

Stylesheets (css and scss)

  • source: src/styles/main.scss and referenced files
  • target: public/assets/styles/main.css
  • processing
    • create main entry point src/styles/main.scss
    • split code into partials
    • include scss or css from node_modules using ~ notation (note: don't use .css suffix as this would create an url() reference)
    • processed scss will be copied to public/assets/styles/main.scss

Scripts (typescript)

  • source: src/scripts/main.ts and referenced files
  • target: public/assets/styles/bundle.js
  • processing
    • create main entry point src/styles/main.ts
    • declare dependencies in package.json, split code into separate .ts files and import in main.ts
    • procecessed bundled.js (including all dependencies) will be copied to public/assets/scripts/bundle.js

php (wordpress theme files)

  • source: src/php/* (style.css, functions.php, index.php, other templates,...)
  • target: public/*
  • processing
    • all theme files and directories are copied directly into public
    • style.css get's current git hash into Version: %git_hash%

Images

  • source: src/images/*
  • target: public/assets/images/*
  • no processing

Fonts

  • source: src/fonts/*

  • target: public/assets/fonts/*

  • no processing