Skip to content

Instantly share code, notes, and snippets.

@MoOx
Last active November 4, 2021 10:19
Show Gist options
  • Select an option

  • Save MoOx/8420645 to your computer and use it in GitHub Desktop.

Select an option

Save MoOx/8420645 to your computer and use it in GitHub Desktop.

Revisions

  1. MoOx revised this gist Feb 20, 2014. 1 changed file with 28 additions and 0 deletions.
    28 changes: 28 additions & 0 deletions output
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,28 @@
    ~/Sync/Development/_clients/idv/ss-front deck-view* 3h 4m 32s
    ❯❯ gulp
    [gulp] Using file /Users/MoOx/Sync/Development/_clients/idv/ss-front/gulpfile.js
    [gulp] Working directory changed to /Users/MoOx/Sync/Development/_clients/idv/ss-front
    rework.properties has been removed.
    [gulp] Running 'clean'...
    [gulp] Finished 'clean' in 993 μs
    [gulp] Running 'install'...
    [gulp] Running 'lint-scripts'...
    [gulp] Finished 'lint-scripts' in 74 ms
    [gulp] Running 'scripts'...
    [gulp] Finished 'scripts' in 4.06 ms
    [gulp] Running 'server'...
    [gulp] Connect server running at http://localhost:9000/
    [gulp] Finished 'server' in 4.03 ms
    [gulp] Running 'styles'...
    [gulp] Finished 'styles' in 19 ms
    [gulp] Running 'html'...
    [gulp] Finished 'html' in 1.07 ms
    [gulp] Running 'static'...
    [gulp] Finished 'static' in 530 μs
    [gulp] Finished 'install' in 106 ms
    [gulp] Running 'dev'...
    [gulp] Running 'server.open'...
    [gulp] Finished 'server.open' in 5.06 ms
    [gulp] Finished 'dev' in 5.6 ms
    [gulp] Running 'default'...
    [gulp] Finished 'default' in 6 μs
  2. MoOx revised this gist Feb 12, 2014. 1 changed file with 74 additions and 30 deletions.
    104 changes: 74 additions & 30 deletions gulpfile.js
    Original file line number Diff line number Diff line change
    @@ -1,16 +1,24 @@
    ///
    var pkg = require("./package.json")
    , rimraf = require("rimraf")
    , gulp = require("gulp")
    , gutil = require("gulp-util")
    , filter = require("gulp-filter")
    , plumber = require("gulp-plumber")
    , concat = require("gulp-concat")

    gulp.task("clean", function() {
    rimraf.sync("./dist/")
    })

    ///
    // HTML (Jade)
    ///
    var jade = require("gulp-jade")
    , htmlFiles = ["./src/html/**/*.jade"]
    gulp.task("html", function() {
    gulp.src(htmlFiles)
    .pipe(plumber())
    .pipe(jade({
    data: pkg
    , pretty: true
    @@ -46,18 +54,28 @@ gulp.task("server.open", function() {
    ///
    var jshint = require("gulp-jshint")
    , jscs = require("gulp-jscs")
    , jsFiles = [
    "*.js"
    , "*.json"
    , jsonFiles = [
    "*.json"
    , ".jshintrc"
    , ".csslintrc"
    ]
    , jsFiles = [
    "*.js"
    , "./src/js/**/*.js"
    ]
    ]
    gulp.task("lint-scripts", function() {
    gulp.src(jsFiles.concat(jsonFiles))
    .pipe(plumber())
    // dont jscs json files
    // .pipe(filter(["!*.json", "!*rc"]))
    // .pipe(jscs())
    // .pipe(filter.end())
    .pipe(jshint(".jshintrc"))
    .pipe(jshint.reporter("jshint-stylish"))

    gulp.src(jsFiles)
    .pipe(plumber())
    .pipe(jscs())
    // .pipe(jshint(".jshintrc"))
    // .pipe(jshint.reporter("jshint-stylish"))
    })

    ///
    @@ -68,18 +86,23 @@ var browserify = require("gulp-browserify")
    "jadeify"
    , "debowerify"
    , "decomponentify"
    , "deamdify"
    // this transform is not working write now
    // something is breaking the process (a semicolon somewhere...)
    //, "deamdify"
    , "deglobalify"
    , "es6ify"
    ]
    if (gulp.env.production) {
    browserifyTransform.push("uglifyify")
    }
    gulp.task("scripts", function() {
    gulp.task("scripts", [
    "lint-scripts"
    ]
    , function() {
    // just grab files that are at the root
    // others files are considered as module
    gulp.src(["./src/js/index.js"])
    .pipe(jshint())
    .pipe(plumber())
    .pipe(browserify({
    transform: browserifyTransform
    //, insertGlobals : true
    @@ -88,8 +111,6 @@ gulp.task("scripts", function() {
    .pipe(concat("index.js"))
    .pipe(gulp.dest("./dist/js/"))
    .pipe(livereload(livereloadServer))

    gulp.run("lint-scripts")
    })

    ///
    @@ -108,17 +129,26 @@ var rework = require("gulp-rework")
    , csso = require("gulp-csso")
    gulp.task("styles", function() {
    gulp.src("./src/css/*.css")
    .pipe(plumber())
    .pipe(
    rework(
    // enhancements
    rework.colors()
    reworkPlugins.imprt("./src/css")
    , rework.colors()
    , rework.references()
    , reworkPlugins.imprt("./src/css")
    // https://github.com/jxson/rework-import/issues/2
    // , reworkPlugins.imprt([
    // "./src/css"
    // , "bower_components"
    // , "node_modules"
    // ])
    , reworkPlugins.parent
    , reworkPlugins.breakpoints
    , reworkPlugins.vars()
    , reworkPlugins.calc
    , reworkPlugins.clearfix
    , rework.ease()
    , rework.extend()
    , {
    sourcemap: true
    }
    @@ -129,7 +159,7 @@ gulp.task("styles", function() {
    .pipe(gulp.dest("./dist/css/"))
    .pipe(livereload(livereloadServer))

    gulp.run("lint-styles")
    //gulp.run("lint-styles")
    })

    ///
    @@ -138,40 +168,54 @@ gulp.task("styles", function() {
    var csslint = require("gulp-csslint")
    gulp.task("lint-styles", function() {
    gulp.src("./dist/css/**/*.css")
    .pipe(plumber())
    .pipe(csslint(".csslintrc"))
    .pipe(csslint.reporter())
    })

    ///
    // Static files
    ///

    var symlink = require("gulp-symlink");
    gulp.task("static", function() {
    gulp.src("./src/static/*")
    .pipe(symlink("dist/"))
    });

    ///
    // Tasks
    ///
    gulp.task("install", function() {
    gulp.task("install", ["clean"], function() {
    gulp.run("scripts")
    gulp.run("styles")
    gulp.run("html")
    gulp.run("static")
    })

    gulp.task("dev", function() {
    gulp.run("install")
    gulp.run("server")
    gulp.run("server.open")
    gulp.task("dev", [
    "install"
    , "server"
    ]
    , function() {
    livereloadServer.listen(pkg.gulp.livereloadServer.port, function(err) {
    if (err) { return gutil.log(err) }

    livereloadServer.listen(pkg.gulp.livereloadServer.port, function(err) {
    if (err) { return gutil.log(err) }
    gulp.watch(["*.js", "./src/js/**/*"], function(event) {
    gulp.run("scripts")
    })

    gulp.watch(jsFiles, function(event) {
    gulp.run("scripts")
    })
    gulp.watch("./src/css/**/*", function(event) {
    gulp.run("styles")
    })

    gulp.watch("./src/css/*.css", function(event) {
    gulp.run("styles")
    gulp.watch("./src/html/**/*", function(event) {
    gulp.run("html")
    })
    })

    gulp.watch(htmlFiles, function(event) {
    gulp.run("html")
    })
    gulp.run("server.open")
    })
    })

    gulp.task("default", function() {
    // remove that task when `gulp --tasks` works
  3. MoOx created this gist Jan 14, 2014.
    184 changes: 184 additions & 0 deletions gulpfile.js
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,184 @@
    ///
    var pkg = require("./package.json")
    , gulp = require("gulp")
    , gutil = require("gulp-util")
    , concat = require("gulp-concat")

    ///
    // HTML (Jade)
    ///
    var jade = require("gulp-jade")
    , htmlFiles = ["./src/html/**/*.jade"]
    gulp.task("html", function() {
    gulp.src(htmlFiles)
    .pipe(jade({
    data: pkg
    , pretty: true
    }))
    .pipe(gulp.dest("./dist/"))
    .pipe(livereload(livereloadServer))
    })

    ///
    // Static server
    ///
    var connect = require("connect")
    , livereloadServer = require("tiny-lr")()
    , livereload = require("gulp-livereload")
    , serverAddress = "http://" + pkg.gulp.server.host + ":" + pkg.gulp.server.port + "/"
    gulp.task("server", function() {
    connect()
    .use(require("connect-livereload")({
    port: pkg.gulp.livereloadServer.port
    }))
    .use(connect.static("./dist"))
    .listen(pkg.gulp.server.port)
    gutil.log("Connect server running at " + serverAddress)
    })
    gulp.task("server.open", function() {
    // src is needed, but not used, cause of gulp way.
    gulp.src("./package.json")
    .pipe(require("gulp-open")("", {url: serverAddress}))
    })

    ///
    // Lint JS
    ///
    var jshint = require("gulp-jshint")
    , jscs = require("gulp-jscs")
    , jsFiles = [
    "*.js"
    , "*.json"
    , ".jshintrc"
    , ".csslintrc"
    , "./src/js/**/*.js"
    ]
    gulp.task("lint-scripts", function() {
    gulp.src(jsFiles)
    .pipe(jscs())
    // .pipe(jshint(".jshintrc"))
    // .pipe(jshint.reporter("jshint-stylish"))
    })

    ///
    // JS
    ///
    var browserify = require("gulp-browserify")
    , browserifyTransform = [
    "jadeify"
    , "debowerify"
    , "decomponentify"
    , "deamdify"
    , "deglobalify"
    , "es6ify"
    ]
    if (gulp.env.production) {
    browserifyTransform.push("uglifyify")
    }
    gulp.task("scripts", function() {
    // just grab files that are at the root
    // others files are considered as module
    gulp.src(["./src/js/index.js"])
    .pipe(jshint())
    .pipe(browserify({
    transform: browserifyTransform
    //, insertGlobals : true
    , debug: gulp.env.production !== undefined
    }))
    .pipe(concat("index.js"))
    .pipe(gulp.dest("./dist/js/"))
    .pipe(livereload(livereloadServer))

    gulp.run("lint-scripts")
    })

    ///
    // CSS
    ///
    var rework = require("gulp-rework")
    , reworkPlugins = {
    imprt: require("rework-import")
    , parent: require("rework-parent")
    , breakpoints: require("rework-breakpoints")
    , vars: require("rework-vars")
    , calc: require("rework-calc")
    , clearfix: require("rework-clearfix")
    }
    , autoprefixer = require("gulp-autoprefixer")
    , csso = require("gulp-csso")
    gulp.task("styles", function() {
    gulp.src("./src/css/*.css")
    .pipe(
    rework(
    // enhancements
    rework.colors()
    , rework.references()
    , reworkPlugins.imprt("./src/css")
    , reworkPlugins.parent
    , reworkPlugins.breakpoints
    , reworkPlugins.vars()
    , reworkPlugins.calc
    , reworkPlugins.clearfix
    , {
    sourcemap: true
    }
    )
    )
    .pipe(autoprefixer())
    .pipe(gulp.env.production ? csso() : gutil.noop())
    .pipe(gulp.dest("./dist/css/"))
    .pipe(livereload(livereloadServer))

    gulp.run("lint-styles")
    })

    ///
    // Lint CSS
    ///
    var csslint = require("gulp-csslint")
    gulp.task("lint-styles", function() {
    gulp.src("./dist/css/**/*.css")
    .pipe(csslint(".csslintrc"))
    .pipe(csslint.reporter())
    })

    ///
    // Tasks
    ///
    gulp.task("install", function() {
    gulp.run("scripts")
    gulp.run("styles")
    gulp.run("html")
    })

    gulp.task("dev", function() {
    gulp.run("install")
    gulp.run("server")
    gulp.run("server.open")

    livereloadServer.listen(pkg.gulp.livereloadServer.port, function(err) {
    if (err) { return gutil.log(err) }

    gulp.watch(jsFiles, function(event) {
    gulp.run("scripts")
    })

    gulp.watch("./src/css/*.css", function(event) {
    gulp.run("styles")
    })

    gulp.watch(htmlFiles, function(event) {
    gulp.run("html")
    })
    })
    })

    gulp.task("default", function() {
    // remove that task when `gulp --tasks` works
    if (gulp.env.tasks) {
    gutil.log(Object.keys(gulp.tasks))
    return
    }

    gulp.run("dev")
    })