Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- BUILD_JS_PATH = 'public/broadmap.js'
- BUILD_CSS_PATH = 'public/broadmap.css'
- tasks =
- watch: ->
- nodewatch = require 'nodewatch'
- _ = require 'underscore'
- _.str = require 'underscore.string'
- # Add folders to be watched
- nodewatch.add('./css').add('./src', true).add('./vendor')
- # Listener
- nodewatch.onChange (file, prev, curr, action)->
- console.log (file + ' changed')
- # Check whether to rebuild css or js
- if _.str.include file, '/bito.broadmap/css/'
- tasks.buildcss()
- else if _.str.include file, '/bito.broadmap/src/' or
- _.str.include file, '/bito.broadmap/vendor/'
- tasks.buildsrc()
- tasks.buildcss()
- tasks.buildsrc()
- console.log 'Watching project'
- buildsrc: ->
- stitch = require 'stitch'
- fs = require 'fs'
- # Create stitch package
- pkg = stitch.createPackage
- paths: [__dirname + '/src']
- dependencies: [
- __dirname + '/vendor/jquery-1.7.1.min.js'
- __dirname + '/vendor/jquery-ui-1.8.18.min.js'
- __dirname + '/vendor/jquery.cookie.js'
- __dirname + '/vendor/jquery.iframe-transport.js'
- __dirname + '/vendor/jquery.fileupload.js'
- ]
- # Compile the package
- pkg.compile (err, src)->
- if err
- console.warn 'Coffee compile failed:'
- console.warn err.toString()
- else
- # Save the source code
- fs.writeFile BUILD_JS_PATH, src, (err)->
- if err then throw err
- console.log 'Compiled src to ' + BUILD_JS_PATH
- buildcss: ->
- stylus = require 'stylus'
- fs = require 'fs'
- # Load the index stylus file
- indexstyl = fs.readFileSync __dirname + '/css/index.styl', 'utf8'
- # Render the stylus
- stylus.render indexstyl, {paths: ['css']}, (err, css)->
- if err
- console.warn 'Stylus compile failed:'
- console.warn err.toString()
- else
- # Save the css to a file
- fs.writeFile BUILD_CSS_PATH, css, 'utf8', (err)->
- if err then throw err
- console.log 'Compiled css to ' + BUILD_CSS_PATH
- build: ->
- tasks.buildsrc()
- tasks.buildcss()
- task 'watch',
- 'Watch and rebuild the project using Node Watcher',
- tasks.watch
- task 'buildsrc',
- 'Build the project coffee-script into the public folder',
- tasks.buildsrc
- task 'buildcss',
- 'Build the project stylus into the public folder',
- tasks.buildcss
- task 'build', 'Builds the Broadmap application to public/', tasks.build
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement