|
| 1 | +"use strict" |
| 2 | + |
| 3 | +# Listen on port 35729 |
| 4 | +LIVERELOAD_PORT = 35729 |
| 5 | + |
| 6 | +lrSnippet = require('connect-livereload')( port: LIVERELOAD_PORT ) |
| 7 | +folderMount = (connect, base) -> |
| 8 | + console.log(base) |
| 9 | + # Serve static files. |
| 10 | + connect.static ( require("path").resolve base ) |
| 11 | + |
| 12 | +module.exports = (grunt) -> |
| 13 | + |
| 14 | + # Project configuration. |
| 15 | + grunt.initConfig |
| 16 | + connect: |
| 17 | + options: |
| 18 | + port: 9000 |
| 19 | + hostname: "localhost" |
| 20 | + dev: |
| 21 | + options: |
| 22 | + middleware: (connect, options) -> |
| 23 | + [ |
| 24 | + lrSnippet |
| 25 | + folderMount(connect, ".tmp/public") |
| 26 | + folderMount(connect, "public") |
| 27 | + ] |
| 28 | + |
| 29 | + dist: |
| 30 | + options: |
| 31 | + middleware: (connect, options) -> |
| 32 | + [ |
| 33 | + lrSnippet |
| 34 | + folderMount(connect, "dist") |
| 35 | + ] |
| 36 | + |
| 37 | + #Set compile settings |
| 38 | + sass: |
| 39 | + dev: |
| 40 | + files: [ |
| 41 | + expand: true |
| 42 | + cwd: "public/css/" |
| 43 | + src: ["**/*.sass","**/*.scss"] |
| 44 | + dest: ".tmp/public/css/" |
| 45 | + ext: ".css" |
| 46 | + ] |
| 47 | + |
| 48 | + less: |
| 49 | + dev: |
| 50 | + files: [ |
| 51 | + expand: true |
| 52 | + cwd: "public/css/" |
| 53 | + src: ["**/*.less"] |
| 54 | + dest: ".tmp/public/css/" |
| 55 | + ext: ".css" |
| 56 | + ] |
| 57 | + |
| 58 | + stylus: |
| 59 | + dev: |
| 60 | + files: [ |
| 61 | + expand: true |
| 62 | + cwd: "public/css/" |
| 63 | + src: ["**/*.styl"] |
| 64 | + dest: ".tmp/public/css/" |
| 65 | + ext: ".css" |
| 66 | + ] |
| 67 | + |
| 68 | + coffee: |
| 69 | + grunt: |
| 70 | + files: |
| 71 | + ".Gruntfile.js": "Gruntfile.coffee" |
| 72 | + |
| 73 | + dev: |
| 74 | + files: [ |
| 75 | + options: |
| 76 | + bare: true |
| 77 | + expand: true |
| 78 | + cwd: "public/js/" |
| 79 | + src: ['**/*.coffee'] |
| 80 | + dest: ".tmp/public/js/" |
| 81 | + ext: '.js' |
| 82 | + ] |
| 83 | + |
| 84 | + typescript: |
| 85 | + dev: |
| 86 | + files: [ |
| 87 | + expand: true |
| 88 | + cwd: "public/js/" |
| 89 | + src: ['**/*.ts'] |
| 90 | + dest: ".tmp/public/js/" |
| 91 | + ext: '.js' |
| 92 | + ] |
| 93 | + |
| 94 | + babel: |
| 95 | + options: |
| 96 | + sourceMap: true |
| 97 | + dev: |
| 98 | + files:[ |
| 99 | + expand: true |
| 100 | + cwd: "public/js/" |
| 101 | + src: ['**/*.es6'] |
| 102 | + dest: ".tmp/public/js/" |
| 103 | + ext: '.js' |
| 104 | + ] |
| 105 | + |
| 106 | +# watch files settings |
| 107 | + watch: |
| 108 | + options: |
| 109 | + livereload: false |
| 110 | + |
| 111 | + sass: |
| 112 | + options: |
| 113 | + cwd: "public/css" |
| 114 | + files: ["**/*.sass", "**/*.scss"] |
| 115 | + tasks: ["sass:dev"] |
| 116 | + |
| 117 | + less: |
| 118 | + options: |
| 119 | + cwd: "public/css" |
| 120 | + files: ["**/*.less"] |
| 121 | + tasks: ["less:dev"] |
| 122 | + |
| 123 | + stylus: |
| 124 | + options: |
| 125 | + cwd: "public/css" |
| 126 | + files: ["**/*.styl"] |
| 127 | + tasks: ["stylus:dev"] |
| 128 | + |
| 129 | + babel: |
| 130 | + options: |
| 131 | + cwd: "public/js" |
| 132 | + files: ["**/*.es6"] |
| 133 | + tasks: ["babel:dev"] |
| 134 | + |
| 135 | + coffee: |
| 136 | + options: |
| 137 | + cwd: "public/js" |
| 138 | + files: ["**/*.coffee"] |
| 139 | + tasks: ["coffee:dev"] |
| 140 | + |
| 141 | + typescript: |
| 142 | + options: |
| 143 | + cwd: "public/js" |
| 144 | + files: ["**/*.ts"] |
| 145 | + tasks: ["typescript:dev"] |
| 146 | + |
| 147 | + plain: |
| 148 | + options: |
| 149 | + cwd: "public" |
| 150 | + livereload: LIVERELOAD_PORT |
| 151 | + files: ["**/*.html", "css/**/*.css", "js/**/*.js"] |
| 152 | + |
| 153 | + compiled: |
| 154 | + options: |
| 155 | + cwd: ".tmp/public" |
| 156 | + livereload: LIVERELOAD_PORT |
| 157 | + files: ["**/*.html", "css/**/*.css", "js/**/*.js"] |
| 158 | + |
| 159 | + clean: |
| 160 | + grunt: |
| 161 | + src: ".Gruntfile.js" |
| 162 | + dev: |
| 163 | + src: [".tmp/**"] |
| 164 | + dist: |
| 165 | + src: ["dist/**"] |
| 166 | + |
| 167 | + copy: |
| 168 | + dist: |
| 169 | + files:[ |
| 170 | + { |
| 171 | + expand: true |
| 172 | + cwd: 'public/' |
| 173 | + src: ["**","!**/*.{coffee,ts,sass,scss,less,styl}"] |
| 174 | + dest: "dist/" |
| 175 | + }, |
| 176 | + { |
| 177 | + expand: true, |
| 178 | + cwd: ".tmp/public/" |
| 179 | + src: ["**"], |
| 180 | + dest: "dist/" |
| 181 | + } |
| 182 | + ] |
| 183 | + |
| 184 | + # browser open |
| 185 | + open: |
| 186 | + server: |
| 187 | + path: "http://localhost:<%= connect.options.port %>" |
| 188 | +# app: 'Google Chrome Canary' |
| 189 | + |
| 190 | + # modules load |
| 191 | + require('matchdep').filterDev('grunt-*').forEach grunt.loadNpmTasks |
| 192 | + |
| 193 | + # task configure |
| 194 | + grunt.registerTask "default", -> |
| 195 | + grunt.task.run ["serve"]; |
| 196 | + |
| 197 | + grunt.registerTask "serve", ["clean", "coffee:grunt", "compile", "connect:dev", "open", "watch"] |
| 198 | + |
| 199 | + grunt.registerTask "build", ["clean", "compile", "copy:dist"] |
| 200 | + |
| 201 | + grunt.registerTask "dist", ["build", "connect:dist", "open", "watch"] |
| 202 | + |
| 203 | + grunt.registerTask "compile", ["babel:dev", "coffee:dev", "typescript:dev", "sass:dev", "less:dev", "stylus:dev"] |
| 204 | + |
0 commit comments