From a510d91460899e344059ff3982892ac3edbd3ac9 Mon Sep 17 00:00:00 2001 From: Saurabh Kumar Date: Sat, 29 Mar 2014 14:03:35 +0530 Subject: [PATCH] Update and rename Gruntfile.js to Gruntfile.coffee Why? It's more pythonic in nature and grunt supports it by default! Why not? Not everyone knows it! but it's no excuse to not use it. It's simple to understand/learn. --- {{cookiecutter.repo_name}}/Gruntfile.coffee | 78 +++++++++++++++ {{cookiecutter.repo_name}}/Gruntfile.js | 101 -------------------- 2 files changed, 78 insertions(+), 101 deletions(-) create mode 100644 {{cookiecutter.repo_name}}/Gruntfile.coffee delete mode 100644 {{cookiecutter.repo_name}}/Gruntfile.js diff --git a/{{cookiecutter.repo_name}}/Gruntfile.coffee b/{{cookiecutter.repo_name}}/Gruntfile.coffee new file mode 100644 index 000000000..6fc0872bc --- /dev/null +++ b/{{cookiecutter.repo_name}}/Gruntfile.coffee @@ -0,0 +1,78 @@ +module.exports = (grunt) -> + appConfig = grunt.file.readJSON("package.json") + + # Load grunt tasks automatically + # see: https://github.com/sindresorhus/load-grunt-tasks + require("load-grunt-tasks")(grunt) + + # Time how long tasks take. Can help when optimizing build times + # see: https://npmjs.org/package/time-grunt + require("time-grunt")(grunt) + pathsConfig = (appName) -> + @app = appName or appConfig.name + app: @app + templates: @app + "/templates" + css: @app + "/static/css" + sass: @app + "/static/sass" + fonts: @app + "/static/fonts" + images: @app + "/static/images" + js: @app + "/static/js" + manageScript: @app + "/manage.py" + + grunt.initConfig + paths: pathsConfig() + pkg: appConfig + + # see: https://github.com/gruntjs/grunt-contrib-watch + watch: + gruntfile: + files: ["Gruntfile.coffee"] + + compass: + files: ["<%= paths.sass %>/**/*.{scss,sass}"] + tasks: ["compass:server"] + + livereload: + files: [ + "<%= paths.js %>/**/*.js" + "<%= paths.sass %>/**/*.{scss,sass}" + "<%= paths.app %>/**/*.html" + ] + options: + spawn: false + livereload: true + + + # see: https://github.com/gruntjs/grunt-contrib-compass + compass: + options: + sassDir: "<%= paths.sass %>" + cssDir: "<%= paths.css %>" + fontsDir: "<%= paths.fonts %>" + imagesDir: "<%= paths.images %>" + relativeAssets: false + assetCacheBuster: false + raw: "Sass::Script::Number.precision = 10\n" + + dist: + options: + environment: "production" + + server: + options: {} + + # see: https://npmjs.org/package/grunt-bg-shell + bgShell: + _defaults: + bg: true + + runDjango: + cmd: "python <%= paths.manageScript %> runserver" + + grunt.registerTask "serve", [ + "bgShell:runDjango" + "watch" + ] + grunt.registerTask "build", ["compass:dist"] + grunt.registerTask "default", ["build"] + return diff --git a/{{cookiecutter.repo_name}}/Gruntfile.js b/{{cookiecutter.repo_name}}/Gruntfile.js deleted file mode 100644 index 2b9f32f19..000000000 --- a/{{cookiecutter.repo_name}}/Gruntfile.js +++ /dev/null @@ -1,101 +0,0 @@ -module.exports = function (grunt) { - - var appConfig = grunt.file.readJSON('package.json'); - - // Load grunt tasks automatically - // see: https://github.com/sindresorhus/load-grunt-tasks - require('load-grunt-tasks')(grunt); - - // Time how long tasks take. Can help when optimizing build times - // see: https://npmjs.org/package/time-grunt - require('time-grunt')(grunt); - - var pathsConfig = function (appName) { - this.app = appName || appConfig.name; - - return { - app: this.app, - templates: this.app + '/templates', - css: this.app + '/static/css', - sass: this.app + '/static/sass', - fonts: this.app + '/static/fonts', - images: this.app + '/static/images', - js: this.app + '/static/js', - manageScript: this.app + '/manage.py' - } - }; - - grunt.initConfig({ - - paths: pathsConfig(), - pkg: appConfig, - - // see: https://github.com/gruntjs/grunt-contrib-watch - watch: { - gruntfile: { - files: ['Gruntfile.js'] - }, - compass: { - files: ['<%= paths.sass %>/**/*.{scss,sass}'], - tasks: ['compass:server'] - }, - livereload: { - files: [ - '<%= paths.js %>/**/*.js', - '<%= paths.sass %>/**/*.{scss,sass}', - '<%= paths.app %>/**/*.html' - ], - options: { - spawn: false, - livereload: true, - }, - }, - }, - - // see: https://github.com/gruntjs/grunt-contrib-compass - compass: { - options: { - sassDir: '<%= paths.sass %>', - cssDir: '<%= paths.css %>', - fontsDir: '<%= paths.fonts %>', - imagesDir: '<%= paths.images %>', - relativeAssets: false, - assetCacheBuster: false, - raw: 'Sass::Script::Number.precision = 10\n' - }, - dist: { - options: { - environment: 'production' - } - }, - server: { - options: { - // debugInfo: true - } - } - }, - - // see: https://npmjs.org/package/grunt-bg-shell - bgShell: { - _defaults: { - bg: true - }, - runDjango: { - cmd: 'python <%= paths.manageScript %> runserver' - } - } - }); - - grunt.registerTask('serve', [ - 'bgShell:runDjango', - 'watch' - ]); - - grunt.registerTask('build', [ - 'compass:dist' - ]); - - grunt.registerTask('default', [ - 'build' - ]); -};