Created
January 22, 2014 22:19
-
-
Save kenelliott/8568584 to your computer and use it in GitHub Desktop.
ember grunt file
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| module.exports = (grunt) -> | |
| # IMPORTS | |
| # ------------------------------------------------------------------------------------ | |
| grunt.loadNpmTasks "grunt-contrib-clean" | |
| grunt.loadNpmTasks "grunt-contrib-coffee" | |
| grunt.loadNpmTasks "grunt-contrib-copy" | |
| grunt.loadNpmTasks "grunt-contrib-connect" | |
| grunt.loadNpmTasks "grunt-contrib-less" | |
| grunt.loadNpmTasks "grunt-contrib-watch" | |
| grunt.loadNpmTasks "grunt-coffeelint" | |
| grunt.loadNpmTasks "grunt-ember-handlebars" | |
| grunt.loadNpmTasks "grunt-contrib-qunit" | |
| # GLOBAL VARS | |
| # ------------------------------------------------------------------------------------ | |
| path = require("path") | |
| lintOptions = require("./coffeelint.json").options | |
| srcFolder = "./src" | |
| devFolder = "./dev" | |
| publicFolder = "./public" | |
| # TASKS DEFINITIONS | |
| # ------------------------------------------------------------------------------------ | |
| grunt.initConfig | |
| # Clean | |
| # ---------------------------------------------------------------------------------- | |
| clean: | |
| all : ["#{devFolder}/*", "#{publicFolder}/*"] | |
| dev : ["#{devFolder}/*"] | |
| public : ["#{publicFolder}/*"] | |
| # Connect | |
| # ---------------------------------------------------------------------------------- | |
| connect: | |
| dev: | |
| options: | |
| port: 8000 | |
| base: "." | |
| keepalive: true | |
| test: | |
| options: | |
| port: 8000 | |
| base: "." | |
| # Lint | |
| # ---------------------------------------------------------------------------------- | |
| coffeelint: | |
| options: lintOptions | |
| gruntfile: ["Gruntfile.coffee"] | |
| sources: | |
| files: [ | |
| expand: true | |
| cwd: "#{srcFolder}app" | |
| src: ["**/*.coffee"] | |
| ] | |
| # Copy | |
| # ---------------------------------------------------------------------------------- | |
| copy: | |
| dev: | |
| files: [ | |
| { | |
| expand: true | |
| cwd: "#{srcFolder}/assets/imgs" | |
| src: ["**"] | |
| dest: "#{devFolder}/assets/imgs" | |
| } | |
| { | |
| expand: true | |
| cwd: "#{srcFolder}/libs" | |
| src: ["**"] | |
| dest: "#{devFolder}/libs" | |
| } | |
| { | |
| expand: true | |
| cwd: "#{srcFolder}" | |
| src: ["index.html"] | |
| dest: "#{devFolder}" | |
| } | |
| { | |
| expand: true | |
| cwd: "#{srcFolder}" | |
| src: ["specs.html"] | |
| dest: "#{devFolder}" | |
| } | |
| ] | |
| public: | |
| files: [ | |
| { | |
| expand: true | |
| cwd: "#{srcFolder}assets/imgs" | |
| src: ["**"] | |
| dest: "#{publicFolder}/assets/imgs" | |
| } | |
| { | |
| expand: true | |
| cwd: "#{srcFolder}libs" | |
| src: ["**"] | |
| dest: "#{publicFolder}/libs" | |
| } | |
| { | |
| expand: true | |
| cwd: "./" | |
| src: ["index.html"] | |
| dest: "#{publicFolder}/" | |
| } | |
| ] | |
| # Ember Templates - I can not get this to run as dev and public tasks..wtf | |
| # ---------------------------------------------------------------------------------- | |
| ember_handlebars: | |
| compile: | |
| options: | |
| processName: (sourceFile) -> | |
| return sourceFile.replace("./src/templates/", "").replace(".hbs","") | |
| files: | |
| "./dev/app/compiled-templates.js": "./src/templates/**/*.hbs" | |
| # CoffeeScript | |
| # ---------------------------------------------------------------------------------- | |
| coffee: | |
| dev: | |
| options: | |
| sourceMap: true | |
| sourceRoot: "" | |
| files: | |
| "./dev/app/app.js": [ | |
| "./src/config/development.coffee" | |
| "./src/app/translations/*.coffee" | |
| "./src/app/initializers/*.coffee" | |
| "./src/app/routers/*.coffee" | |
| "./src/app/constants/*.coffee" | |
| "./src/app/mixins/*.coffee" | |
| "./src/app/controllers/*.coffee" | |
| "./src/app/serializers/*.coffee" | |
| "./src/app/transforms/*.coffee" | |
| "./src/app/models/*.coffee" | |
| "./src/app/routes/*.coffee" | |
| "./src/app/helpers/*.coffee" | |
| "./src/app/views/*.coffee" | |
| "./src/app/fixtures/*.coffee" | |
| "./src/config/standalone.coffee" | |
| ] | |
| "./dev/specs.js": [ | |
| "./src/config/development.coffee" | |
| "./src/specs/helpers.coffee" | |
| "./src/specs/setup.coffee" | |
| "./src/specs/**/*.coffee" | |
| ] | |
| # LESS | |
| # ---------------------------------------------------------------------------------- | |
| less: | |
| dev: | |
| files: | |
| [ | |
| { | |
| src: ["#{srcFolder}/assets/css/main.less"] | |
| dest: "#{devFolder}/assets/css/main.css" | |
| } | |
| ] | |
| public: | |
| options: | |
| yuicompress: true | |
| files: | |
| [ | |
| { | |
| src: ["#{srcFolder}/assets/css/main.less"] | |
| dest: "#{publicFolder}/assets/css/main.css" | |
| } | |
| ] | |
| # Watch | |
| # ---------------------------------------------------------------------------------- | |
| watch: | |
| options: | |
| livereload: true | |
| templates: | |
| files: "#{srcFolder}/templates/**/*.hbs" | |
| tasks: ["ember_handlebars"] | |
| options: | |
| nospawn: true | |
| coffee: | |
| files: "#{srcFolder}/**/*.coffee" | |
| tasks: ["coffee"] | |
| options: | |
| sourceMap: true | |
| sourceRoot: "" | |
| less: | |
| files: "#{srcFolder}/**/*.less" | |
| tasks: ["less:dev"] | |
| html: | |
| files: "#{srcFolder}/**/*.html" | |
| tasks: ["copy"] | |
| qunit: | |
| test: | |
| options: | |
| timeout: 10000 | |
| urls: ['http://localhost:8000/dev/specs.html'] | |
| # WATCH EVENT | |
| # ------------------------------------------------------------------------------------ | |
| grunt.event.on "watch", (action, filepath) -> | |
| cwd = "#{srcFolder}" | |
| filepath = filepath.replace cwd, "" | |
| isCoffee = path.extname(filepath) == ".coffee" | |
| isHTML = path.extname(filepath) == ".html" | |
| isHBS = path.extname(filepath) == ".hbs" | |
| if isHTML | |
| grunt.config.set "copy", | |
| templates: | |
| files: [ | |
| expand: true | |
| cwd: cwd | |
| src: filepath | |
| dest: devFolder | |
| ] | |
| grunt.task.run "copy:templates" | |
| if isCoffee | |
| grunt.config.set "coffee", | |
| options: lintOptions | |
| changed: | |
| bare: false | |
| expand: true | |
| cwd: cwd | |
| src: filepath | |
| dest: "#{devFolder}/app/app.js" | |
| options: | |
| sourceMap: true | |
| sourceRoot: "" | |
| grunt.config.set "coffeelint", | |
| options: lintOptions | |
| newSources: | |
| files: [ | |
| expand: true | |
| cwd: cwd | |
| src: filepath | |
| ] | |
| grunt.task.run "coffeelint:newSources" | |
| grunt.task.run "coffee:changed" | |
| if isHBS | |
| grunt.task.run "ember_handlebars" | |
| # REGISTERED TASKS | |
| # ------------------------------------------------------------------------------------ | |
| grunt.registerTask "default", [ | |
| "dev" | |
| "connect:dev" | |
| ] | |
| grunt.registerTask "dev", [ | |
| "coffeelint" | |
| "clean:dev" | |
| "coffee:dev" | |
| "less:dev" | |
| "copy:dev" | |
| "ember_handlebars" | |
| ] | |
| grunt.registerTask "test", [ | |
| "coffeelint" | |
| "clean:dev" | |
| "coffee:dev" | |
| "less:dev" | |
| "copy:dev" | |
| "ember_handlebars" | |
| "connect:test" | |
| "qunit:test" | |
| ] | |
| grunt.registerTask "public", [ | |
| "coffeelint" | |
| "clean:public" | |
| "less:public" | |
| "copy:public" | |
| "ember_handlebars" | |
| ] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment