mirror of
https://github.com/koodiklinikka/koodiklinikka.fi.git
synced 2026-02-06 20:49:49 +00:00
use the same tasks for production & development build
production state is determined with the NODE_ENV variable from this point forwards
This commit is contained in:
11
README.md
11
README.md
@@ -24,9 +24,16 @@
|
||||
* npm start
|
||||
* Compiles your files, starts watching files for changes, serves static files to port 9001
|
||||
* npm run build
|
||||
* Builds & minifies everything
|
||||
* Builds everything
|
||||
|
||||
Minification, uglification and other tasks you're expected to run before deploying your product can be made by running the build command with env variable NODE_ENV set to "production"
|
||||
|
||||
NODE_ENV=production npm run build
|
||||
|
||||
|
||||
## Adding 3rd party libraries
|
||||
**Note**: If the package you are looking for can be found in NPM it's much easier to install it from there. After installing packages from NPM they can be required without any of the following instructions.
|
||||
|
||||
bower install jquery --save
|
||||
|
||||
Now to use jQuery in your frontend code, you'll need to add jQuery to "browser" and "browserify-shim" sections of your package.json. Your package.json should be something like this:
|
||||
@@ -46,7 +53,7 @@ Now to use jQuery in your frontend code, you'll need to add jQuery to "browser"
|
||||
|
||||
Now your should be able to require jQuery in your coffee files
|
||||
|
||||
$ = require 'jquery'
|
||||
$ = require 'jquery'
|
||||
|
||||
|
||||
## Development guidelines
|
||||
|
||||
@@ -18,60 +18,50 @@ plumber = require 'gulp-plumber'
|
||||
prefix = require 'gulp-autoprefixer'
|
||||
reloadServer = lr()
|
||||
|
||||
compileCoffee = (debug = false) ->
|
||||
production = process.env.NODE_ENV is 'production'
|
||||
|
||||
gulp.task 'coffee', ->
|
||||
|
||||
bundle = watchify('./src/coffee/main.coffee')
|
||||
|
||||
rebundle = ->
|
||||
|
||||
build = bundle.bundle(debug: debug)
|
||||
build = bundle.bundle(debug: not production)
|
||||
.pipe(source('bundle.js'))
|
||||
|
||||
build.pipe(streamify(uglify())) unless debug
|
||||
build.pipe(streamify(uglify())) if production
|
||||
|
||||
build
|
||||
.pipe(gulp.dest('./public/js/'))
|
||||
.pipe(livereload(reloadServer))
|
||||
|
||||
bundle.on 'update', rebundle
|
||||
bundle.on 'update', rebundle unless production
|
||||
|
||||
rebundle()
|
||||
|
||||
compileJade = (debug = false) ->
|
||||
gulp.task 'jade', ->
|
||||
gulp
|
||||
.src('src/jade/*.jade')
|
||||
.pipe(jade(pretty: debug))
|
||||
.pipe(jade(pretty: not production))
|
||||
.pipe(gulp.dest('public/'))
|
||||
.pipe livereload(reloadServer)
|
||||
|
||||
compileStylus = (debug = false) ->
|
||||
gulp.task 'stylus', ->
|
||||
styles = gulp
|
||||
.src('src/stylus/style.styl')
|
||||
.pipe(stylus({set: ['include css']}))
|
||||
.pipe(prefix("last 1 version", "> 1%", "ie 8"))
|
||||
|
||||
styles.pipe(CSSmin()) unless debug
|
||||
styles.pipe(CSSmin()) if production
|
||||
|
||||
styles.pipe(gulp.dest('public/css/'))
|
||||
.pipe livereload reloadServer
|
||||
|
||||
copyAssets = (debug = false) ->
|
||||
gulp.task 'assets', ->
|
||||
gulp
|
||||
.src('src/assets/**/*.*')
|
||||
.pipe gulp.dest 'public/'
|
||||
|
||||
# Build tasks
|
||||
gulp.task "jade-production", -> compileJade()
|
||||
gulp.task 'stylus-production', ->compileStylus()
|
||||
gulp.task 'coffee-production', -> compileCoffee()
|
||||
gulp.task 'assets-production', -> copyAssets()
|
||||
|
||||
# Development tasks
|
||||
gulp.task "jade", -> compileJade(true)
|
||||
gulp.task 'stylus', -> compileStylus(true)
|
||||
gulp.task 'coffee', -> compileCoffee(true)
|
||||
gulp.task 'assets', -> copyAssets(true)
|
||||
|
||||
gulp.task "server", ->
|
||||
staticFiles = new nodeStatic.Server './public'
|
||||
require('http').createServer (req, res) ->
|
||||
@@ -88,5 +78,5 @@ gulp.task "watch", ->
|
||||
gulp.watch "src/stylus/*.styl", ["stylus"]
|
||||
gulp.watch "src/assets/**/*.*", ["assets"]
|
||||
|
||||
gulp.task "build", ["coffee-production", "jade-production", "stylus-production", "assets-production"]
|
||||
gulp.task "default", ["coffee", "jade", "stylus", "assets", "watch", "server"]
|
||||
gulp.task "build", ["coffee", "jade", "stylus", "assets"]
|
||||
gulp.task "default", ["build", "watch", "server"]
|
||||
|
||||
Reference in New Issue
Block a user