Giter Club home page Giter Club logo

template-gulp's Introduction

template-gulp

npm dependencies

Example Gulp.js workflow with all the file structure you need to get started with Gulp.js and a number of the most helpful modules for a front-end developer.

This uses SCSS with Autoprefixer, minify and concat for JS, BrowserSync for automatic page refreshing, and Jekyll to generate a static site or blog, with more too (optionally).

I've written a detailed blog article about how to install and use this if it's your first time working with Gulp.

Prerequisites

If you want to run a static site (not required if you just want to process CSS/JS/images):

If you want to publish to GitHub:

  • Git, which you can get through installing GitHub Desktop which installs git.

There's an alternate way to publish if you don't want to use git.

Installation

If you plan to publish a site, I strongly recommend you clone this repo as that will make it a breeze for you to publish to GitHub Pages later. If you have GitHub Desktop, you can just click "Clone in Desktop" down the right side of this GitHub repo page.

If you're not publishing, you can manually download the starter files.

Once you've got the project starter files, navigate to the directory where you put them. From here, install the dependencies by running:

npm install gulp-sass gulp-autoprefixer gulp-imagemin imagemin-pngquant gulp-concat gulp-uglify browser-sync gulp-gh-pages --save-dev 

Pay special attention to gulpfile.js, that's where all the magic happens.

Without Jekyll

If you don't want to use Jekyll as a part of this (so if you only want to compile your SCSS and other assets), you need to comment out the Jekyll parts of the gulpfile.js (it's annotated), and delete _config.yml, src/_includes, src/_layouts and src/index.md.

Since Jekyll is what generates the HTML files, you'll need to manually add an index.html file to dist. Make sure it has the following in the <head>:

<link rel="stylesheet" href="css/application.css">
<script src="js/application.js"></script>

Usage

While in the project root, start the server by running:

gulp

Deploying

To GitHub Pages

git is required for this.

From the project root, run:

gulp deploy

Because you cloned this repo, your project root has all the necessary files so that the deploy command can automatically create the gh-pages branch (on the first time you run the command) and publish the contents of your dist folder there. Your site will be live a few minutes later at [github-username].github.io/[repo-name]. GitHub will email you when the site is published. You can also use your own domain name for free.

Surge is my preferred way to deploy static sites. It's free, offers all the same features as GitHub Pages, and doesn't require your code be open which makes it ideal for client sites. It also doesn't require git.

It isn't included in the dependencies of this project by default, so you'll need to install it. Once installed, run:

surge dist

(Typing dist tells it to just upload your compiled site, otherwise it'll upload everything.) It'll help you sign up for a Surge account (email & password) from the command line, and by default deploys to a .surge.sh subdomain, but much like with GitHub Pages you can [use your own domain name for free](https://surge.sh/help/adding-a-custom-domain name).

Base file structure

dist/
    css/
        application.css
    js/
        application.js
    img/
        example.png
    index.html
src/
    _includes/
        head.html
    _layouts/
        default.html
    img/
        example.png
    js/
        example1.js
        example2.js
    scss/
        main.scss
    index.md
_config.yml
gulpfile.js
package.json

template-gulp's People

Contributors

ara303 avatar edadams avatar

Stargazers

Shiva Narrthine avatar Ajmal Afif avatar  avatar

Watchers

 avatar

template-gulp's Issues

Production-safe to do list

A list of tasks and dependencies I want to have running before I could comfortably say that I'm ready to use this in a production environment.

For testing:

  • browsersync for local testing and automatic refreshing with LiveReload

For CSS:

  • gulp-sass for SCSS compilation and minifying
  • gulp-autoprefixer for vendor prefixing, 2 versions back

For HTML:

  • A static site tool (probably Jekyll since it seems to be what everyone else uses!)

For JS:

  • gulp-concat for concatenating
  • gulp-uglify for minifying

For images:

  • gulp-imagemin

For deploying to a server:

  • Surge -- Not actually in the build process but I know how to use it, and this will probably be how I host because publishing to Surge seems better than GitHub Pages.
  • gulp-gh-pages -- While not my ideal way to host static sites, I feel more confident betting on GitHub still being here in 5 years than Surge, so I'd like to know how to deploy to both.

"Nice To Have" extras:

  • Webpack/Bower/some sort of JS dependency manager. I don't know the first thing about these, so I'd like to research them.
  • Consider the pros and cons of replacing SCSS with PostCSS in the future.

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.