Skip to content

Instantly share code, notes, and snippets.

@gaboesquivel
Last active August 29, 2015 13:57
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save gaboesquivel/9433595 to your computer and use it in GitHub Desktop.
Save gaboesquivel/9433595 to your computer and use it in GitHub Desktop.
ngbp with grunt-contrib-connect
# The actual `grunt serve` settings
connect:
options:
port: 9000
hostname: "localhost"
# livereload: 35729
dist:
options:
base: "<%= build_dir %>"
open: true
###
The Karma configurations.
###
karma:
options:
configFile: "karma.conf.js"
unit:
runnerPort: 9101 #IMPORTANT! http://bit.ly/1dCd0n7
background: true
continuous:
singleRun: true
delta:
###
By default, we want the Live Reload to work for all tasks; this is
overridden in some tasks (like this file) where browser resources are
unaffected. It runs by default on port 35729, which your browser
plugin should auto-detect.
###
options:
livereload: true
###
When the Gruntfile changes, we just want to lint it. In fact, when
your Gruntfile changes, it will automatically be reloaded!
###
gruntfile:
files: "Gruntfile.coffee"
tasks: ["jshint:gruntfile"]
options:
livereload: false
###
When our JavaScript source files change, we want to run lint them and
run our unit tests.
###
jssrc:
files: ["<%= app_files.js %>"]
tasks: [
"jshint:src"
"karma:unit:run"
"copy:build_appjs"
]
###
When our CoffeeScript source files change, we want to run lint them and
run our unit tests.
###
coffeesrc:
files: ["<%= app_files.coffee %>"]
tasks: [
"coffeelint:src"
"coffee:source"
"karma:unit:run"
"copy:build_appjs"
]
###
When assets are changed, copy them. Note that this will *not* copy new
files, so this is probably not very useful.
###
assets:
files: ["src/assets/**/*"]
tasks: ["copy:build_assets"]
###
When index.html changes, we need to compile it.
###
html:
files: ["<%= app_files.html %>"]
tasks: ["index:build"]
###
When our templates change, we only rewrite the template cache.
###
tpls:
files: [
"<%= app_files.atpl %>"
"<%= app_files.ctpl %>"
]
tasks: ["html2js"]
###
When the CSS files change, we need to compile and minify them.
###
less:
files: ["src/**/*.less"]
tasks: ["less:build"]
###
When a JavaScript unit test file changes, we only want to lint it and
run the unit tests. We don't want to do any live reloading.
###
jsunit:
files: ["<%= app_files.jsunit %>"]
tasks: [
"jshint:test"
"karma:unit:run"
]
options:
livereload: false
###
When a CoffeeScript unit test file changes, we only want to lint it and
run the unit tests. We don't want to do any live reloading.
###
coffeeunit:
files: ["<%= app_files.coffeeunit %>"]
tasks: [
"coffeelint:test"
"karma:unit:run"
]
options:
livereload: false
###
In order to make it safe to just compile or copy *only* what was changed,
we need to ensure we are starting from a clean, fresh build. So we rename
the `watch` task to `delta` (that's why the configuration var above is
`delta`) and then add a new task called `watch` that does a clean build
before watching for changes.
###
grunt.initConfig grunt.util._.extend(taskConfig, userConfig)
grunt.renameTask "watch", "delta"
grunt.registerTask "watch", [
"build"
"karma:unit"
"delta"
]
###
The `build` task gets the app ready to run for development and testing.
###
grunt.registerTask "build", [
"clean"
"html2js"
"jshint"
"coffeelint"
"coffee"
"less:build"
"concat:build_css"
"copy:build_app_assets"
"copy:build_vendor_assets"
"copy:build_appjs"
"copy:build_vendorjs"
"index:build"
"karma:continuous"
]
###
The `serve` task gets your app ready to run for development and testing.
###
grunt.registerTask "serve", (target) ->
if target is "dist"
return grunt.task.run([
"build"
"compile"
"connect:dist:keepalive"
])
#default does not call compile
grunt.task.run [
"watch"
"connect:dist:keepalive"
]
return
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment