Install - logaegae/project_study GitHub Wiki

How to install grunt on Ubuntu

Grunt is a Javascript task runner that can be used to compile Sass, Less or run many other plugins. It depends on theNode.js package manager (npm) So, First to do is install node.js

Install nodejs, npm, and grunt-cli

$ sudo apt-get install curl
$ curl -sL https://deb.nodesource.com/setup_6.x | sudo -E bash -
$ sudo apt-get install -y nodejs

$ sudo npm install -g grunt-cli 

Install grunt in your project directory

$ cd ~/myproject 
$ echo "{}" > package.json 
$ npm install grunt --save-dev 

Verify grunt is installed

$ nodejs --version 
v0.10.33
$ npm --version 
1.4.28
$ grunt --version 
grunt-cli v0.1.13
grunt v0.4.5

Create a package.json file

$ npm init

Install grunt-contrib-uglify

$ npm install 

Create a Gruntfile.js file:

module.exports = function(grunt){
   
    
// Project configuration. 

grunt.initConfig({
  concat: {
    //  concat 시작 
    css: {
      src: ['libs/css/*.css'],
      dest: 'css/default.css',
    },
    js: {
      src: ['libs/js/*.js'],
      dest: 'js/default.js',
    }
    //concat 끝
  },
  watch: {
    //   watch stat
        css: {
            files: ['libs/css/*.css'],
            tasks: ['concat'],
        },
        js: {
            files: ['libs/**/*.js'],
            tasks: ['concat'],
        },
        less:{
            files: ['libs/**/*.less'],
            tasks: ['less'],
        }
    // watch end
    },
    less:{
        development:{
            options:{
                paths:["libs/less"],
            },
            files:{
                'libs/css/less.css' : 'libs/less/*.less'
            }
        },
    },
    
});

grunt.loadNpmTasks('grunt-contrib-concat');
grunt.loadNpmTasks('grunt-contrib-watch');
grunt.loadNpmTasks('grunt-contrib-less');
    
}

Run the grunt task

$ grunt 
⚠️ **GitHub.com Fallback** ⚠️