Skip to content

ferrimor/dev4.space

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

dev4.space

A single page website developed with gulp

  1. Create a new project $ mkdir project-name cd into the new directory
  2. Initialize NPM: $ npm init --yes
  3. Install gulp and gulp-sass packages: $ npm install -D gulp gulp-sass browser-sync
  4. Update package.json's scripts section with this key-value pair: "scripts": { "dev": "gulp" }
  5. Recreate this file structure in this directory:
  • public (directory)
    • css (directory)
    • index.html (file)
  • scss (directory)
    • partials (directory)
    • styles.scss (file)
  • gulpfile.js (file)
  • package.json (created by npm init --yes)
  1. Add the following code into the file gulpfile.js:
var gulp        = require('gulp');
var browserSync = require('browser-sync').create();
var sass        = require('gulp-sass');

// Static Server + watching scss/html files
gulp.task('serve', function() {

  browserSync.init({
      server: "./public"
  });

  gulp.watch("scss/**/*.scss", ['sass']);
  gulp.watch("public/*.html").on('change', browserSync.reload);
});

// Compile sass into CSS & auto-inject into browsers
gulp.task('sass', function() {
  return gulp.src("scss/styles.scss")
    .pipe(sass().on('error', sass.logError))
    .pipe(gulp.dest("public/css"))
    .pipe(browserSync.stream());
});

gulp.task('default', ['sass', 'serve']);
  1. Add the following code into the file scss/styles.scss:
body {
  background-color: red;
  
  h1 {
    color: purple;
  }
}
  1. Add the following code into the file public/index.html:
<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <title>Sass Gulp Workshop</title>
  <link rel="stylesheet" href="/css/styles.css">
</head>
<body>
  <h1>Hello Syntatically Awesome Style Sheets!</h1>
</body>
</html>
  1. start developing: npm run dev

About

A single page website developed with gulp

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors