GithubHelp home page GithubHelp logo

orlovmax / gulp-workflow Goto Github PK

View Code? Open in Web Editor NEW
6.0 1.0 0.0 2.6 MB

Gulp-based build tool with Pug, Sass, Rollup, PostCSS, BrowserSync

License: MIT License

JavaScript 38.26% Pug 10.91% Sass 50.83%

gulp-workflow's Introduction

Gulp Workflow

Gulp-based build tool with Pug, Sass, Rollup, PostCSS, BrowserSync

Contents

Requirements

How To Start

  • 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.json by running: npm install
  • Start development by running npm start or gulp
  • See Tasks and Configuration for more details

If you haven't used Gulp before, be sure to check out the Gulp - Getting Started.

Folder And File Structure

./
├── .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

Reserved Folders

html, css, stylus, videos folder names in src are reserved by preconfigured inactive tasks, see Inactive Tasks.

Configuration

  • .editorconfig file at the root of the project describes indentation style, trailing whitespaces etc. See EditorConfig site for more details.
  • src/pug/config.json contains data for pug templates: site settings, meta information, links to css / js files or external fonts.

Tasks

Cleanup

npm run cleanup or gulp cleanup

  • Removes .gitkeep placeholders from work directories.

Development

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

Production

npm run prod or gulp prod

  • Empties dist folder
  • 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

Demonstration

npm run demo or gulp demo \

  • Runs static server.

Inactive Tasks

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 in gulpfile.js
  • add htmlDev to dev and htmlProd to prod series in gulpfile.js
  • uncomment import { htmlDevChanged } from './html.js'; and Watch HTML sections in ./gulp/watch.js
  • create html folder in src
    ./
    └── 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 in gulpfile.js
  • add cssDev to dev and cssProd to prod series in gulpfile.js
  • uncomment import { cssDev } from './css.js'; and Watch css sections in ./gulp/watch.js
  • create css folder in src
    ./
    └── 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 in gulpfile.js
  • add stylusDev to dev and stylusProd to prod series in gulpfile.js
  • uncomment import { stylusDev } from './stylus.js'; and Watch stylus sections in ./gulp/watch.js
  • create stylus folder in src
./
└── 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 in gulpfile.js
  • add videosDev to dev and videosProd to prod series in gulpfile.js
  • uncomment import { videosDevChanged } from './videos.js'; and Watch videos sections in ./gulp/watch.js
  • create videos folder in src
./
└── src/
    └── videos/                                * video sources

License

MIT

gulp-workflow's People

Contributors

orlovmax avatar

Stargazers

zero avatar Cybersecurity & Privacy | Developer websites avatar Aman Gupta avatar Smalyik avatar  avatar  avatar

Watchers

 avatar

gulp-workflow's Issues

Browser-sync usage

In some case, it might be easier to use browser-sync module instead of heavy standalone server.

CoffeeScript support

Add coffee task and modify folder structure for further middleman experiments with Sass, Jade, Coffee stack

Reorganize tags

Do something with those tags. They should be related to appropriate branches

Gulp scaffold fonts task

Fix bug in fonts copy task - it will copy not only fonts, but also txt, config.json etc. Need some filter for this

Add grid

Add simple grid as additional elements

Modify preprocess task

Modify preprocess task for using context instead of echo conditions. For this project and for grunt-boilerplate

Browserify usage

Take a look on browserify and its grunt implementation. Grunt-rowserify vs grunt-concat + Bower

Build tasks improvement

Target build tasks to files in build directory with rewriting instead of processing them from dev

Gulp scaffold: add run sequence for tasks

Ex. Concatenate and copy files to other folder. For now Gulp is copying files while concatenating them and as a result we have a bunch of original files without concatenated file.

Custom.css option

Just thought that customm.css might be a good option for current scaffold. It has sence when someone want to change style of some element without changing original stylesheets. ( For some hacks or some workarounds, lol)

Modify .htaccess cache rules

Add .hataccess rules for caching css, js etc > 1month. Now there is a cache busting option so it seems to be possible

Block oriented structure

In separate branch create BEM oriented structure instead of current tech-oriented structure.. It means that each block will be presented as folder that contain block realization in markup, styles and js.

Styles structure upd

Current issue refers to #12
The point is that styles file structure should be similar to templates, except creating layouts. Styles are totally reusable - presented as independent blocks, even layout blocks.
The structure should look like this:

  • styles
    • screen.sass
    • components folder // Independent components and/or blocks
      • general folder // Common used styles, related to curent project
        • reset.sass
        • fonts.sass
      • block-name.sass
    • helpers folder // Third-party independent components and libs
      • mixin.sass
      • variables.sass

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.