Gulp-based build tool with Pug, Sass, Rollup, PostCSS, BrowserSync
- Install Node.js >=16
- Install gulp-cli globally
npm install --global gulp-cli - Download this repo using git
git clone https://github.com/orlovmax/gulp-workflow.git - Go to downloaded folder
cd gulp-workflow - Install dependencies from
package.jsonby running:npm install - Start development by running
npm startorgulp - See Tasks and Configuration for more details
If you haven't used Gulp before, be sure to check out the Gulp - Getting Started.
./
├── .editorconfig
├── .gitignore
├── gulpfile.js
├── package.json
├── README.md
├── LICENSE.md
|
├── gulp/ * gulp tasks
| ├── _config.js * tasks config
| └── task.js
|
├── src/ * site source
| ├── pug/ * pug templates
| | ├── blocks/ * blocks
| │ | └── block.pug
| │ ├── helpers/ * helper mixins
| │ ├── vendor/ * third-party code
| │ ├── layouts/ * page layouts
| │ ├── pages/ * page templates
| │ └── config.json * site config
| │
| ├── sass/ * sass stylesheets
| | ├── blocks/ * blocks
| │ | └── block.sass
| │ ├── helpers/ * mixins and vars
| │ ├── vendor/ * third-party code
| │ ├── custom.sass
| │ ├── noscript.sass
| │ └── screen.sass
| │
│ ├── js/ * scripts
| | ├── vendor/ * third-party code
| | ├── modules/ * modules
| │ ├── head.js * head scripts
| │ └── body.js * body scripts
| │
│ ├── fonts/ * font sources
| │
│ ├── images/ * image sources
| │
│ └── helpers/ * helper files
│ └── favicon.ico
|
├── build/ * site build
│ ├── index.html
│ ├── page.html
│ └── static/ * static assets
│ ├── css/ * compiled stylesheets with sourcemaps
│ ├── js/ * bundled scripts
│ ├── fonts/ * webfonts
│ └── images/ * images
│
└── dist/ * site distribution (Ignored by GIT)
├── index.html
├── page.html
└── static/ * static assets
├── css/ * minified compiled stylesheets
├── js/ * minified bundled scripts
├── fonts/ * webfonts
└── images/ * images
html, css, stylus, videos folder names in src are reserved by preconfigured inactive tasks, see Inactive Tasks.
.editorconfigfile at the root of the project describes indentation style, trailing whitespaces etc. See EditorConfig site for more details.src/pug/config.jsoncontains data for pug templates: site settings, meta information, links to css / js files or external fonts.
npm run cleanup or gulp cleanup
- Removes .gitkeep placeholders from work directories.
npm start or npm run dev or gulp dev
- Compiles pug templates
- Compiles sass stylesheets, combines media queries, adds vendor prefixes, generates sourcemaps
- Bundles scripts
- Copies fonts
- Copies images
- Copies helpers
- Runs BrowserSync static server with live reload
- Watches for changes and run dev tasks
npm run prod or gulp prod
- Empties
distfolder - Compiles pug templates, minifies markup
- Compiles sass stylesheets, combines media queries, adds vendor prefixes, minifies stylesheets
- Bundles scripts, minifies scripts
- Copies fonts
- Copies images
- Copies helpers
- Runs BrowserSync static server
npm run demo or gulp demo \
- Runs static server.
Preconfigured tasks but disabled in current version (commented-out and not imported), see gulpfile.js and watch.js.
html (html.js)
Dev: copies html markup
Prod: copies and minifies html markup
How To Activate:
- uncomment
import { htmlDev, htmlProd } from './gulp/html.js';section ingulpfile.js - add
htmlDevtodevandhtmlProdtoprodseries ingulpfile.js - uncomment
import { htmlDevChanged } from './html.js';andWatch HTMLsections in./gulp/watch.js - create
htmlfolder insrc./ └── src/ └── html/ * html markup └── file.html
css (css.js)
Dev: copies css stylesheets, inlines imports, combines media queries, adds vendor prefixes
Prod: copies css stylesheets, inlines imports, combines media queries, adds vendor prefixes, minifies stylesheets
How To Activate:
- uncomment
import { cssDev, cssProd } from './gulp/css.js';section ingulpfile.js - add
cssDevtodevandcssProdtoprodseries ingulpfile.js - uncomment
import { cssDev } from './css.js';andWatch csssections in./gulp/watch.js - create
cssfolder insrc./ └── src/ └── css/ * css stylsheets ├── blocks/ | └── block.css ├── helpers/ ├── vendor/ ├── custom.css ├── noscript.css └── screen.css
stylus (stylus.js)
Dev: compiles stylus stylesheets, combines media queries, adds vendor prefixes, generates sourcemaps
Prod: compiles stylus stylesheets, combines media queries, adds vendor prefixes, minifies stylesheets
How To Activate:
- uncomment
import { stylusDev, stylusProd } from './gulp/stylus.js';section ingulpfile.js - add
stylusDevtodevandstylusProdtoprodseries ingulpfile.js - uncomment
import { stylusDev } from './stylus.js';andWatch stylussections in./gulp/watch.js - create
stylusfolder insrc
./
└── src/
└── stylus/ * stylus stylesheets
├── blocks/
| └── block.styl
├── helpers/
├── vendor/
├── custom.styl
├── noscript.styl
└── screen.styl
videos (videos.js)
Dev / Prod: copies videos
How To Activate:
- uncomment
import { videosDev, videosProd } from './gulp/videos.js';section ingulpfile.js - add
videosDevtodevandvideosProdtoprodseries ingulpfile.js - uncomment
import { videosDevChanged } from './videos.js';andWatch videossections in./gulp/watch.js - create
videosfolder insrc
./
└── src/
└── videos/ * video sources