• This repository has been archived on 16/Mar/2021
  • Stars
    star
    846
  • Rank 53,868 (Top 2 %)
  • Language
    JavaScript
  • License
    MIT License
  • Created over 10 years ago
  • Updated almost 4 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

A boilerplate for building web projects with Gulp.js.

Gulp Boilerplate Build Status

A boilerplate for building web projects with Gulp. Uses Gulp 4.x.

IMPORTANT: This project is no longer maintained, and is offered as-is. It is strongly recommended that you instead use my Build Tool Boilerplate.

Features

  • Concatenate, minify, and lint JavaScript.
  • Compile, minify, autoprefix, and lint Sass.
  • Optimize SVGs.
  • Copy static files and folders into your dist directory.
  • Automatically add headers and project details to JS and CSS files.
  • Create polyfilled and non-polyfilled versions of JS files.
  • Watch for file changes, and automatically recompile build and reload webpages.

Gulp Boilerplate makes it easy to turn features on and off, so you can reuse it for all of your projects without having to delete or modify tasks.

Getting Started

Dependencies

Note: if you've previously installed Gulp globally, run npm rm --global gulp to remove it. Details here.

Make sure these are installed first.

Quick Start

  1. In bash/terminal/command line, cd into your project directory.
  2. Run npm install to install required files and dependencies.
  3. When it's done installing, run one of the task runners to get going:
    • gulp manually compiles files.
    • gulp watch automatically compiles files and applies changes using BrowserSync when you make changes to your source files.

Try it out. After installing, run gulp to compile some test files into the dist directory. Or, run gulp watch and make some changes to see them recompile automatically.

Documentation

Add your source files to the appropriate src subdirectories. Gulp will process and and compile them into dist.

  • JavaScript files in the src/js directory will be compiled to dist/js. Files in subdirectories under the js folder will be concatenated. For example, files in js/detects will compile into detects.js.
  • Files in the src/sass directory will be compiled to dist/css.
  • SVG files placed in the src/svg directory will be optimized with SVGO and compiled into dist/svg.
  • Files and folders placed in the copy directory will be copied as-is into the dist directory.

package.json

The package.json file holds all of the details about your project.

Some information is automatically pulled in from it and added to a header that's injected into the top of your JavaScript and CSS files.

{
	"name": "project-name",
	"version": "0.0.1",
	"description": "A description for your project.",
	"main": "./dist/your-main-js-file.js",
	"author": {
		"name": "YOUR NAME",
		"url": "http://link-to-your-website.com"
	},
	"license": "MIT",
	"repository": {
		"type": "git",
		"url": "http://link-to-your-git-repo.com"
	},
	"devDependencies": {}
}

Note: devDependencies are the dependencies Gulp uses. Don't change these or you'll break things. If any of the other fields are removed, make sure to remove reference to them in the Header (under var banner in gulpfile.js) or gulp watch won't run.

JavaScript

Put your JavaScript files in the src/js directory.

Files placed directly in the js folder will compile directly to dist/js as both minified and unminified files. Files placed in subdirectories under src/js will also be concatenated into a single file. For example, files in js/detects will compile into detects.js.

A note about polyfills: In subdirectories that contain files with the .polyfill.js suffix (for example, _matches.polyfill.js), two versions will be created: one with the polyfill files, and one without.

Sass

Put your Sass files in the src/sass directory.

Gulp generates minified and unminified CSS files. It also includes autoprefixer, which adds vendor prefixes for you.

SVGs

Place SVG files in the src/svg directory.

SVG files will be optimized with SVGO and compiled into dist/svg.

Copy Files

Files and folders placed in the src/copy directory will be copied as-is into dist.

This is a great place to put HTML files, images, and pre-compiled assets.

Options & Settings

Gulp Boilerplate makes it easy to customize for projects without having to delete or modify tasks.

Options and settings are located at the top of the gulpfile.js.

Settings

Set features under the settings variable to true to turn them on (default), and false to turn them off.

/**
 * Settings
 * Turn on/off build features
 */

var settings = {
	clean: true,
	scripts: true,
	polyfills: true,
	styles: true,
	svgs: true,
	copy: true,
	reload: true
};

Paths

Adjust the input and output paths for all of the Gulp tasks under the paths variable. Paths are relative to the root project folder.

/**
 * Paths to project folders
 */

var paths = {
	input: 'src/',
	output: 'dist/',
	scripts: {
		input: 'src/js/*',
		// polyfills: '!src/js/*.polyfill.js',
		polyfills: '.polyfill.js',
		output: 'dist/js/'
	},
	styles: {
		input: 'src/sass/**/*.{scss,sass}',
		output: 'dist/css/'
	},
	svgs: {
		input: 'src/svg/*.svg',
		output: 'dist/svg/'
	},
	copy: {
		input: 'src/copy/*',
		output: 'dist/'
	},
	reload: './dist/'
};

Header

Gulp auto-injects a header into all of your JavaScript and CSS files with details from your package.json file.

You can change what's included under the banner variable.

/**
 * Template for banner to add to file headers
 */

var banner = {
	full:
		'/*!\n' +
		' * <%= package.name %> v<%= package.version %>\n' +
		' * <%= package.description %>\n' +
		' * (c) ' + new Date().getFullYear() + ' <%= package.author.name %>\n' +
		' * <%= package.license %> License\n' +
		' * <%= package.repository.url %>\n' +
		' */\n\n',
	min:
		'/*!' +
		' <%= package.name %> v<%= package.version %>' +
		' | (c) ' + new Date().getFullYear() + ' <%= package.author.name %>' +
		' | <%= package.license %> License' +
		' | <%= package.repository.url %>' +
		' */\n'
};

License

The code is available under the MIT License.

More Repositories

1

smooth-scroll

A lightweight script to animate scrolling to anchor links.
JavaScript
5,481
star
2

reef

A lightweight library for creating reactive, state-based components and UI.
JavaScript
1,113
star
3

kraken

A lightweight, mobile-first boilerplate for front-end web developers.
HTML
768
star
4

gumshoe

A simple vanilla JS scrollspy script.
JavaScript
731
star
5

social-sharing

Add social sharing links and buttons without the bloat.
CSS
641
star
6

tabby

Lightweight, accessible vanilla JS toggle tabs.
JavaScript
577
star
7

atomic

A tiny, Promise-based vanilla JS Ajax/HTTP plugin with great browser support.
HTML
540
star
8

build-tool-boilerplate

A simple boilerplate for using NPM tasks to build and compile JavaScript, CSS, and image files.
JavaScript
488
star
9

bouncer

A lightweight form validation script that augments native HTML5 form validation elements and attributes.
JavaScript
308
star
10

validate

A lightweight form validation script.
JavaScript
230
star
11

houdini

A simple, accessible show-and-hide/accordion script.
JavaScript
158
star
12

ebook-boilerplate

A lightweight boilerplate for self-publishing ebooks with markdown and command line.
CSS
135
star
13

htaccess

[DEPRECATED] Best practice server rules for making web pages fast and secure.
ApacheConf
93
star
14

slider

[DEPRECATED] A simple, fluid, touch-enabled carousel.
JavaScript
87
star
15

right-height

Dynamically set content areas of different lengths to the same height.
CSS
87
star
16

modals

Simple modal dialogue windows
JavaScript
85
star
17

bin

A tiny (<1kb) localStorage and sessionStorage helper library.
JavaScript
84
star
18

vanilla-javascript-cheat-sheet

Moved
80
star
19

vanilla-js-toolkit

A growing collection of vanilla JavaScript code snippets, helper functions, polyfills, plugins, and learning resources.
CSS
79
star
20

drop

A small CSS component that turns browser-native <details> elements into dropdown menus.
JavaScript
75
star
21

form-saver

A simple script that lets users save and reuse form data.
JavaScript
68
star
22

hugo-starter

A barebones starter project and theme for learning Hugo.
HTML
67
star
23

gmt-wordpress-for-web-apps

[DEPRECATED] A plugin that provides the essential components you need to power your web app with WordPress.
PHP
67
star
24

events

A tiny event delegation library.
JavaScript
62
star
25

gmt-html-minify

Minify your HTML output in WordPress.
PHP
61
star
26

buoy

[DEPRECATED] A lightweight collection of helper methods for getting stuff done with native JavaScript.
JavaScript
54
star
27

astro

Mobile-first navigation patterns.
JavaScript
53
star
28

sticky-footer

Dynamic, responsive sticky footers.
JavaScript
47
star
29

keel

A lightweight boilerplate for WordPress theme developers.
JavaScript
46
star
30

x-ray

X-Ray is a script that lets users toggle password visibility in forms.
JavaScript
46
star
31

table-of-contents

Automatically generate a table of contents from the headings on the page.
JavaScript
39
star
32

jar

A tiny (< 1kb) library that makes working with cookies easier.
JavaScript
38
star
33

saferInnerHTML

Set the HTML of an element while protecting yourself from XSS attacks.
JavaScript
29
star
34

dom-manipulation-source-code

HTML
24
star
35

gmt-image-compress-and-sharpen

[DEPRECATED] Change the default WordPress compression rate for JPGs, convert images to progressive JPGs, and sharpen images.
PHP
19
star
36

learn-vanilla-js

A roadmap for learning vanilla JavaScript
HTML
19
star
37

jellyfish

[DEPRECATED] A progressively enhanced image lazy loader.
JavaScript
18
star
38

frontend-horse-js-library

The boilerplate for the Frontend Horse livestream.
JavaScript
17
star
39

state-based-ui-source-code

JavaScript
15
star
40

petfinderAPI4everybody

A JavaScript plugin that makes it easier to use the Petfinder API.
JavaScript
14
star
41

vanilla-js-guides

HTML
14
star
42

wp-shopping-cart

[DEPRECATED - DO NOT USE] A simple PayPal shopping cart for WordPress.
PHP
14
star
43

alerts

Simple alert messages.
JavaScript
14
star
44

wp-theme-options

[DEPRECATED] Create a theme options menu that admin can use to adjust theme settings from the dashboard.
PHP
14
star
45

reef-js

The website for ReefJS.
HTML
14
star
46

progress-bars

Simple CSS progress bars.
CSS
13
star
47

writing-libraries-source-code

HTML
13
star
48

learn-vanilla-js-source-code

HTML
12
star
49

kelp

A collection of small functions for creating reactive, state-based UIs.
JavaScript
12
star
50

project-star-rating-system

A vanilla JavaScript project
HTML
11
star
51

gmt-mailchimp-wp-rest-api

Add WP Rest API hooks for JS use of the Mailchimp API.
PHP
11
star
52

apis-source-code

HTML
11
star
53

vanilla-js-list

A growing list of organizations that build sites and apps with vanilla JS
CSS
10
star
54

petfinder-api-for-wordpress

A collection of functions to help you display Petfinder listings on your WordPress site.
PHP
10
star
55

browser-storage-source-code

HTML
10
star
56

gmt-pricing-parity

Display country-specific EDD discounts to visitors.
PHP
9
star
57

vanilla-js-academy

PHP
9
star
58

gmt-remove-header-junk

[DEPRECATED] Remove the unneccessary junk WordPress adds to the header.
PHP
9
star
59

snapshot

Simple image styling.
CSS
9
star
60

dom-injection-source-code

HTML
8
star
61

the-lean-web

CSS
8
star
62

sw-fonts

Demo for https://gomakethings.com/improving-web-font-performance-with-service-workers/
HTML
8
star
63

gmt-paypal-ipn-forwarder

[DEPRECATED] Forward PayPal IPN to multiple other IPN services in WordPress.
PHP
8
star
64

service-worker-pages-demo

A demo for https://gomakethings.com/saving-recently-viewed-pages-with-service-workers-and-vanilla-js/
HTML
8
star
65

gmt-slack-invites-for-edd

[DEPRECATED] Automatically invite members to your Slack team when they purchase a product.
PHP
8
star
66

vanilla-js-guidebook-labs

The labs for "The Vanilla JS Guidebook."
HTML
7
star
67

service-workers-source-code

JavaScript
7
star
68

sw-offline-first

Demo for https://gomakethings.com/offline-first-with-service-workers-and-vanilla-js/
HTML
7
star
69

harbor-wp-theme

A free mobile-friendly WordPress theme built specifically for animal rescue organizations.
JavaScript
7
star
70

adventure

A simplish, imagination-based kitchen table RPG.
CSS
7
star
71

vanilla-js-projects

HTML
6
star
72

games

Simple vanilla JS game demos.
HTML
6
star
73

variable-function-scope-source-code

HTML
6
star
74

gmt-automated-slack-invites

Automate Slack invites with WordPress.
PHP
6
star
75

google-hosted-jquery

[DEPRECATED] Use the Google CDN version of jQuery in WordPress, with a local fallback.
PHP
6
star
76

gomakethings

The WordPress theme for Go Make Things
JavaScript
5
star
77

service-worker-demo

A demo for https://gomakethings.com/writing-your-first-service-worker-with-vanilla-js/
HTML
5
star
78

origami

[DEPRECATED] Origami has been merged into the Kraken front-end boilerplate and is no longer supported.
HTML
5
star
79

timezones

Easily calculate timezones for your next meeting.
HTML
4
star
80

arrays-objects-source-code

HTML
4
star
81

labels

Lightweight CSS labels.
CSS
4
star
82

gmt-antispambot

A shortcode for the antispambot function that's built into WordPress.
PHP
4
star
83

cferdinandi

4
star
84

web-components-source-code

HTML
4
star
85

string-array-object-source-code

HTML
4
star
86

vanilla-js-podcast

A show about JavaScript for people who hate the complexity of modern front‑end web development.
CSS
4
star
87

es-modules-demo

https://gomakethings.com/an-intro-to-import-and-export-with-es-modules/
JavaScript
3
star
88

javascript-essentials-source-code

Source code for the JavaScript Essentials workshop.
HTML
3
star
89

accessible-components-source-code

HTML
3
star
90

es-modules-source-code

JavaScript
3
star
91

ajax-source-code

HTML
3
star
92

strings-numbers-source-code

HTML
3
star
93

go-mobile-first

[DEPRECATED] A mobile-first boilerplate for WordPress.
PHP
3
star
94

gmt-allow-iframes

[DEPRECATED] Prevent wp_kses from removing iframe embeds
PHP
3
star
95

gmt-donations

[DEPRECATED] A WordPress plugin that lets you create powerful donation forms that integrate with Stripe and PayPal Express Checkout.
PHP
3
star
96

token-based-authentication-source-code

HTML
3
star
97

advanced-academy-common-issue-not-modularizing-your-code-enough

JavaScript
3
star
98

fetch

The Fetch for Petfinder plugin
JavaScript
2
star
99

es-modules-default

https://gomakethings.com/how-to-define-a-default-export-with-vanilla-js-es-modules/
JavaScript
2
star
100

careers

CSS
2
star