Skip to content

Instantly share code, notes, and snippets.

@dennisreimann
Created October 16, 2014 05:12
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dennisreimann/8fc20fb68f33c50c121b to your computer and use it in GitHub Desktop.
Save dennisreimann/8fc20fb68f33c50c121b to your computer and use it in GitHub Desktop.
gulp setup for building node-webkit apps
{
"coffeescript_error": {
"level": "error"
},
"arrow_spacing": {
"name": "arrow_spacing",
"level": "ignore"
},
"no_tabs": {
"name": "no_tabs",
"level": "error"
},
"no_trailing_whitespace": {
"name": "no_trailing_whitespace",
"level": "error",
"allowed_in_comments": false,
"allowed_in_empty_lines": true
},
"max_line_length": {
"name": "max_line_length",
"value": 250,
"level": "error",
"limitComments": true
},
"line_endings": {
"name": "line_endings",
"level": "ignore",
"value": "unix"
},
"no_trailing_semicolons": {
"name": "no_trailing_semicolons",
"level": "error"
},
"indentation": {
"name": "indentation",
"value": 2,
"level": "error"
},
"camel_case_classes": {
"name": "camel_case_classes",
"level": "error"
},
"colon_assignment_spacing": {
"name": "colon_assignment_spacing",
"level": "ignore",
"spacing": {
"left": 0,
"right": 0
}
},
"no_implicit_braces": {
"name": "no_implicit_braces",
"level": "ignore",
"strict": true
},
"no_plusplus": {
"name": "no_plusplus",
"level": "ignore"
},
"no_throwing_strings": {
"name": "no_throwing_strings",
"level": "error"
},
"no_backticks": {
"name": "no_backticks",
"level": "error"
},
"no_implicit_parens": {
"name": "no_implicit_parens",
"level": "ignore"
},
"no_empty_param_list": {
"name": "no_empty_param_list",
"level": "ignore"
},
"no_stand_alone_at": {
"name": "no_stand_alone_at",
"level": "ignore"
},
"space_operators": {
"name": "space_operators",
"level": "ignore"
},
"duplicate_key": {
"name": "duplicate_key",
"level": "error"
},
"empty_constructor_needs_parens": {
"name": "empty_constructor_needs_parens",
"level": "ignore"
},
"cyclomatic_complexity": {
"name": "cyclomatic_complexity",
"value": 10,
"level": "ignore"
},
"newlines_after_classes": {
"name": "newlines_after_classes",
"value": 3,
"level": "ignore"
},
"no_unnecessary_fat_arrows": {
"name": "no_unnecessary_fat_arrows",
"level": "warn"
},
"missing_fat_arrows": {
"name": "missing_fat_arrows",
"level": "ignore"
},
"non_empty_constructor_needs_parens": {
"name": "non_empty_constructor_needs_parens",
"level": "ignore"
}
}
gulp = require("gulp")
gulpif = require("gulp-if")
del = require("del")
jade = require("gulp-jade")
gutil = require("gulp-util")
coffee = require("gulp-coffee")
concat = require("gulp-concat")
stylus = require("gulp-stylus")
uglify = require("gulp-uglify")
plumber = require("gulp-plumber")
prefix = require("gulp-autoprefixer")
webserver = require("gulp-webserver")
minifyCSS = require("gulp-minify-css")
coffeelint = require('gulp-coffeelint')
runSequence = require('run-sequence')
resolveDependencies = require("gulp-resolve-dependencies")
ngAnnotate = require("gulp-ng-annotate")
NwBuilder = require("node-webkit-builder")
path =
scripts: ["app/scripts/vendor/**/*.js", "app/scripts/**/*.coffee"]
static: ["app/package.json", "app/images/**"]
stylus: ["app/styles/**/*.styl", "!app/styles/lib/*", "!app/styles/themes/_*"]
jade: ["app/views/**/*.jade", "!app/views/shared/*.jade"]
clean: [".tmp", "build", "dist"]
nodewebkit: ["build/**/*"]
gulp.task "clean", (cb) ->
del(path.clean, cb)
gulp.task "scripts", ->
gulp.src(path.scripts)
.pipe(plumber())
.pipe(gulpif(/[.]coffee$/, coffeelint("coffeelint.json")))
.pipe(gulpif(/[.]coffee$/, coffeelint.reporter()))
.pipe(gulpif(/[.]coffee$/, coffee()))
.pipe(ngAnnotate())
.pipe(uglify())
.pipe(concat("app.js"))
.pipe(gulp.dest("build/scripts/"))
gulp.task "styles", ->
gulp.src(path.stylus)
.pipe(plumber())
.pipe(stylus(paths: ["app/styles/lib"], import: ["mediaQueries", "variables"]))
.pipe(prefix("last 1 version"))
.pipe(minifyCSS())
.pipe(gulpif(/themes\/.*[.]css$/, gutil.noop(), concat("app.css")))
.pipe(gulp.dest('build/styles/'))
gulp.task "html", ->
gulp.src(path.jade)
.pipe(plumber())
.pipe(resolveDependencies({pattern: /^\s*(?:extends|include) ([\w-]+)$/g}))
.pipe(jade())
.pipe(gulp.dest("build/"))
gulp.task "static", ->
gulp.src(path.static)
.pipe(gulp.dest("build/"))
gulp.task "webserver", ->
gulp.src("build/")
.pipe(webserver(livereload: true))
gulp.task "watch", ->
gulp.watch path.scripts, ["scripts"]
gulp.watch path.stylus, ["styles"]
gulp.watch path.jade, ["html"]
gulp.watch path.static, ["static"]
gulp.watch path.nodewebkit, ["nodewebkit"]
gulp.task "nodewebkit", ->
nw = new NwBuilder(
platforms: ["osx"]
buildDir: "dist"
cacheDir: ".cache"
files: path.nodewebkit
)
nw.on("log", (msg) -> gutil.log("node-webkit-builder", msg))
nw.build().catch((err) -> gutil.log("node-webkit-builder", err))
gulp.task "build", (cb) -> runSequence("clean", ["scripts", "html", "styles", "static"], "nodewebkit", cb)
gulp.task "develop", (cb) -> runSequence("build", ["webserver", "watch"], cb)
gulp.task "default", ["build"]
{
"version": "0.0.0",
"name": "gulp-setup",
"description": "gulp setup for building node-webkit apps",
"dependencies": {},
"devDependencies": {
"gulp": "^3.8.7",
"gulp-autoprefixer": "0.0.8",
"gulp-coffee": "^2.1.1",
"gulp-concat": "^2.3.4",
"gulp-ng-annotate": "^0.3.3",
"gulp-if": "^1.2.4",
"gulp-jade": "^0.7.0",
"gulp-minify-css": "^0.3.7",
"gulp-plumber": "^0.6.4",
"gulp-resolve-dependencies": "^1.0.1",
"gulp-sourcemaps": "^1.1.1",
"gulp-stylus": "^1.3.0",
"gulp-uglify": "^0.3.1",
"gulp-util": "^3.0.0",
"gulp-webserver": "^0.6.0",
"gulp-coffeelint": "^0.4.0",
"run-sequence": "^1.0.1",
"del": "^0.1.3",
"jade": "^1.7.0",
"stylus": "^0.48.1",
"coffee-script": "^1.7.1",
"node-webkit-builder": "^0.1.3"
},
"engines": {
"node": ">=0.8.0"
},
"scripts": {
"start": "gulp develop"
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment