sudo npm update -g npm
sudo npm install -g grunt-cli
sudo npm install --save grunt
sudo npm install --save-dev grunt-contrib-jshint grunt-contrib-nodeunit grunt-contrib-uglify
#installing ruby and sass
sudo apt-get install ruby-full build-essential rubygems
sudo gem install sass
mkdir src test assets
touch gruntfile.js
Last active
December 7, 2017 10:17
-
-
Save tojibon/3f7c65655f514f0c5f62ed3429cd9582 to your computer and use it in GitHub Desktop.
Starting a Grunt Project
This file contains 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 = function(grunt) { | |
grunt.initConfig({ | |
pkg: grunt.file.readJSON('package.json'), | |
concat: { | |
options: { | |
// define a string to put between each file in the concatenated output | |
separator: '' | |
}, | |
dist: { | |
// the files to concatenate | |
src: ['src/assets/js/*.js'], | |
// the location of the resulting JS file | |
dest: 'src/assets/public/js/<%= pkg.name %>.js' | |
} | |
}, | |
uglify: { | |
options: { | |
manage: false, | |
preserveComments: 'all', | |
// the banner is inserted at the top of the output | |
banner: '/*! <%= pkg.name %> <%= grunt.template.today("dd-mm-yyyy") %> */\n' | |
}, | |
dist: { | |
files: { | |
'src/assets/public/js/<%= pkg.name %>.min.js': ['<%= concat.dist.dest %>'] | |
} | |
} | |
}, | |
qunit: { | |
files: ['test/**/*.html'] | |
}, | |
jshint: { | |
// define the files to lint | |
files: ['gruntfile.js', 'src/assets/js/*.js', 'test/**/*.js'], | |
// configure JSHint (documented at http://www.jshint.com/docs/) | |
options: { | |
// more options here if you want to override JSHint defaults | |
globals: { | |
jQuery: true, | |
console: true, | |
module: true, | |
document: true | |
} | |
} | |
}, | |
sass: { | |
dist: { | |
files: [{ | |
expand: true, | |
cwd: 'src/assets/sass', | |
src: ['*.scss'], | |
dest: 'src/assets/css', | |
ext: '.css' | |
}] | |
} | |
}, | |
cssmin: { | |
target: { | |
files: [{ | |
expand: true, | |
cwd: 'src/assets/css', | |
src: ['*.css', '!*.min.css'], | |
dest: 'src/assets/public/css', | |
ext: '.min.css' | |
}] | |
} | |
}, | |
cssconcat: { | |
options: { | |
// define a string to put between each file in the concatenated output | |
separator: '' | |
}, | |
dist: { | |
// the files to concatenate | |
src: ['src/assets/css/*.css'], | |
// the location of the resulting JS file | |
dest: 'src/assets/public/css/<%= pkg.name %>.css' | |
} | |
}, | |
watch: { | |
files: ['<%= jshint.files %>'], | |
tasks: ['jshint', 'qunit'] | |
} | |
}); | |
grunt.loadNpmTasks('grunt-contrib-uglify'); | |
grunt.loadNpmTasks('grunt-contrib-jshint'); | |
grunt.loadNpmTasks('grunt-contrib-qunit'); | |
grunt.loadNpmTasks('grunt-contrib-watch'); | |
grunt.loadNpmTasks('grunt-contrib-cssmin'); | |
grunt.loadNpmTasks('grunt-contrib-sass'); | |
grunt.loadNpmTasks('grunt-contrib-concat'); | |
// this would be run by typing "grunt test" on the command line | |
grunt.registerTask('test', ['jshint', 'qunit']); | |
// the default task can be run just by typing "grunt" on the command line | |
grunt.registerTask('default', ['jshint', 'qunit', 'concat', 'uglify', 'sass', 'cssmin']); | |
}; |
This file contains 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
{ | |
"name": "grunt-starter", | |
"version": "1.0.0", | |
"description": "", | |
"main": "index.js", | |
"scripts": { | |
"test": "echo \"Error: no test specified\" && exit 1" | |
}, | |
"author": "Juyal Ahmed", | |
"license": "ISC", | |
"devDependencies": { | |
"grunt-contrib-concat": "^1.0.1", | |
"grunt-contrib-cssmin": "^2.2.1", | |
"grunt-contrib-jshint": "^1.1.0", | |
"grunt-contrib-nodeunit": "^1.0.0", | |
"grunt-contrib-qunit": "^2.0.0", | |
"grunt-contrib-sass": "^1.0.0", | |
"grunt-contrib-uglify": "^3.2.1", | |
"grunt-contrib-watch": "^1.0.0", | |
"matchdep": "^2.0.0" | |
}, | |
"dependencies": { | |
"grunt": "^0.4.5", | |
"node-sass": "^4.7.2", | |
"grunt-sass": "^2.0.0" | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment