Permalink
Browse files

Improve development workflow

  • Loading branch information...
1 parent 41acc9a commit 1941fa759f7d66c92c3b966cf0d09324dda42474 @Kikobeats committed Sep 24, 2016
Showing with 23 additions and 21 deletions.
  1. +1 −1 .bumpedrc
  2. +13 −20 gulpfile.coffee
  3. +9 −0 package.json
View
@@ -14,7 +14,7 @@ plugins:
'Compiling browser version':
plugin: 'bumped-terminal'
- command: 'gulp build'
+ command: 'NODE_ENV=production gulp build'
'Generating CHANGELOG file':
plugin: 'bumped-changelog'
View
@@ -3,6 +3,7 @@
# -- Dependencies --------------------------------------------------------------
gulp = require 'gulp'
+gulpif = require 'gulp-if'
gutil = require 'gulp-util'
sass = require 'gulp-sass'
concat = require 'gulp-concat'
@@ -12,15 +13,13 @@ uglify = require 'gulp-uglify'
cssnano = require 'gulp-cssnano'
addsrc = require 'gulp-add-src'
changed = require 'gulp-changed'
+browserSync = require 'browser-sync'
pkg = require './package.json'
prefix = require 'gulp-autoprefixer'
strip = require 'gulp-strip-css-comments'
-browserSync = require 'browser-sync'
reload = browserSync.reload
-PORT =
- GHOST: 2387
- BROWSERSYNC: 3000
+isProduction = process.env.NODE_ENV is 'production'
# -- Files ---------------------------------------------------------------------
@@ -67,40 +66,34 @@ gulp.task 'js-common', ->
.pipe coffee().on 'error', gutil.log
.pipe addsrc src.js.common.vendor
.pipe concat dist.name + '.common.js'
- .pipe uglify()
- .pipe header banner, pkg: pkg
+ .pipe gulpif(isProduction, uglify())
+ .pipe gulpif(isProduction, header banner, pkg: pkg)
.pipe gulp.dest dist.js
return
gulp.task 'js-post', ->
gulp.src src.js.post
.pipe changed dist.js
.pipe concat dist.name + '.post.js'
- .pipe uglify()
- .pipe header banner, pkg: pkg
+ .pipe gulpif(isProduction, uglify())
+ .pipe gulpif(isProduction, header banner, pkg: pkg)
.pipe gulp.dest dist.js
return
gulp.task 'css', ->
gulp.src src.css.vendor
.pipe changed dist.css
.pipe addsrc src.sass.main
- .pipe sass().on 'error', gutil.log
+ .pipe sass().on('error', sass.logError)
.pipe concat '' + dist.name + '.css'
- .pipe prefix()
- .pipe strip
- all: true
- .pipe cssnano()
- .pipe header banner, pkg: pkg
+ .pipe gulpif(isProduction, prefix())
+ .pipe gulpif(isProduction, strip all: true)
+ .pipe gulpif(isProduction, cssnano())
+ .pipe gulpif(isProduction, header banner, pkg: pkg)
.pipe gulp.dest dist.css
return
-gulp.task 'server', ->
- browserSync.init
- proxy: "http://127.0.0.1:#{PORT.GHOST}"
- port: PORT.BROWSERSYNC
- files: ['assets/**/*.*']
- return
+gulp.task 'server', -> browserSync.init(pkg.browserSync)
gulp.task 'js', ['js-common', 'js-post']
gulp.task 'build', ['css', 'js']
View
@@ -33,11 +33,20 @@
"gulp-concat": "latest",
"gulp-cssnano": "latest",
"gulp-header": "latest",
+ "gulp-if": "latest",
"gulp-sass": "latest",
"gulp-strip-css-comments": "latest",
"gulp-uglify": "latest",
"gulp-util": "latest"
},
+ "browserSync": {
+ "proxy": "http://127.0.0.1:2387",
+ "port": 3000,
+ "files": [
+ "**/*.html",
+ "assets/**/*.*"
+ ]
+ },
"engines": {
"node": "^4.2.0"
},

0 comments on commit 1941fa7

Please sign in to comment.