Skip to content

Instantly share code, notes, and snippets.

@roachhd
Last active August 29, 2015 14:09
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save roachhd/e46ec8418b01021cd0be to your computer and use it in GitHub Desktop.
Save roachhd/e46ec8418b01021cd0be to your computer and use it in GitHub Desktop.
grunty grunt stuff

#Get Grunting baby

Must have nodejs, grunt, npm, Not to mention you'll need to get grunt init

#####After that's done then start a grunting baby 😉

grunt-init gruntfile initializes a basic gruntfile. More details

grunt-init-gruntfile

Create a basic Gruntfile with grunt-init.

Installation

If you haven't already done so, install grunt-init.

Once grunt-init is installed, place this template in your ~/.grunt-init/ directory. It's recommended that you use git to clone this template into that directory, as follows:

git clone https://github.com/gruntjs/grunt-init-gruntfile.git ~/.grunt-init/gruntfile

(Windows users, see the documentation for the correct destination directory path)

Usage

At the command-line, cd into an empty directory, run this command and follow the prompts.

grunt-init gruntfile

Note that this template will generate files in the current directory, so be sure to change to a new directory first if you don't want to overwrite existing files.

######sample gruntfile output from grunt init gruntfile

/*global module:false*/
module.exports = function(grunt) {


  // Project configuration.
  grunt.initConfig({
    // Metadata.
    pkg: grunt.file.readJSON('package.json'),
    banner: '/*! <%= pkg.title || pkg.name %> - v<%= pkg.version %> - ' +
      '<%= grunt.template.today("yyyy-mm-dd") %>\n' +
      '<%= pkg.homepage ? "* " + pkg.homepage + "\\n" : "" %>' +
      '* Copyright (c) <%= grunt.template.today("yyyy") %> <%= pkg.author.name %>;' +
      ' Licensed <%= _.pluck(pkg.licenses, "type").join(", ") %> */\n',
    // Task configuration.
    concat: {
      options: {
        banner: '<%= banner %>',
        stripBanners: true
      },
      dist: {
        src: ['lib/<%= pkg.name %>.js'],
        dest: 'dist/<%= pkg.name %>.js'
      }
    },
    uglify: {
      options: {
        banner: '<%= banner %>'
      },
      dist: {
        src: '<%= concat.dist.dest %>',
        dest: 'dist/<%= pkg.name %>.min.js'
      }
    },
    jshint: {
      options: {
        curly: true,
        eqeqeq: true,
        immed: true,
        latedef: true,
        newcap: true,
        noarg: true,
        sub: true,
        undef: true,
        unused: true,
        boss: true,
        eqnull: true,
        browser: true,
        globals: {}
      },
      gruntfile: {
        src: 'Gruntfile.js'
      },
      lib_test: {
        src: ['lib/**/*.js', 'test/**/*.js']
      }
    },
    qunit: {
      files: ['test/**/*.html']
    },
    watch: {
      gruntfile: {
        files: '<%= jshint.gruntfile.src %>',
        tasks: ['jshint:gruntfile']
      },
      lib_test: {
        files: '<%= jshint.lib_test.src %>',
        tasks: ['jshint:lib_test', 'qunit']
      }
    }
  });


  // Default task.
  grunt.registerTask('default', ['jshint', 'qunit', 'concat', 'uglify']);


};

#my bestest grunt plugs

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment