diff --git a/Gruntfile.js b/Gruntfile.js new file mode 100644 index 0000000..8392cd9 --- /dev/null +++ b/Gruntfile.js @@ -0,0 +1,83 @@ +var path = require('path'), + fs = require('fs'); + +module.exports = function(grunt) { + grunt.initConfig({ + less: { + development: { + files: [{ + src: 'less/main.less', + dest: 'style.css' + }] + }, + production: { + options: { + plugins: require('less-plugin-clean-css')() + }, + files: [{ + src: 'less/main.less', + dest: 'style.css' + }] + } + }, + uglify: { + production: { + files: { + 'main.js': 'js/**/*.js' + } + } + }, + injector: { + options: { + transform: function(file) { + var ext = path.extname(file).slice(1); + + switch (ext) { + case 'css': + return ''; + case 'js': + return ''; + case 'html': + return fs.readFileSync(__dirname + file); + } + } + }, + development: { + files: { + 'index.html': ['js/libs/*.js', 'js/*.js', + 'style.css', 'partials/**/*.html'], + 'how.html': ['js/libs/*.js', 'js/*.js', + 'style.css', 'partials/0-header.html', + 'partials/how*.html'] + } + }, + production: { + files: { + 'index.html': ['main.js', 'style.css', 'partials/**/*.html'], + 'how.html': ['main.js', 'style.css', + 'partials/0-header.html', 'partials/how*.html'] + } + } + }, + watch: { + styles: { + files: ['less/**/*.less'], + tasks: ['less'] + }, + partials: { + files: ['partials/**/*.html'], + tasks: ['injector'] + } + } + }); + + grunt.loadNpmTasks('grunt-contrib-less'); + grunt.loadNpmTasks('grunt-contrib-watch'); + grunt.loadNpmTasks('grunt-contrib-uglify'); + grunt.loadNpmTasks('grunt-asset-injector'); + + grunt.registerTask('default', ['less:development', 'injector:development']); + grunt.registerTask('production', ['less:production', + 'uglify:production', + 'injector:production']); +}; diff --git a/package.json b/package.json new file mode 100644 index 0000000..76a96e5 --- /dev/null +++ b/package.json @@ -0,0 +1,40 @@ +{ + "name": "", + "version": "0.1.0", + "description": "", + "main": "index.js", + "scripts": { + "test": "grunt test" + }, + "repository": { + "type": "git", + "url": "https://github.com/mdibaiee/" + }, + "keywords": [], + "author": "Mahdi Dibaiee", + "license": "MIT", + "bugs": { + "url": "https://github.com/mdibaiee//issues" + }, + "files": [ + "types", + "build", + "index.js" + ], + "directories": { + "lib": "lib" + }, + "engines": { + "node": ">=0.12.0" + }, + "homepage": "https://github.com/mdibaiee/", + "dependencies": {}, + "devDependencies": { + "grunt": "^0.4.5", + "grunt-asset-injector": "^0.1.0", + "grunt-contrib-less": "^1.0.1", + "grunt-contrib-uglify": "^0.9.2", + "grunt-contrib-watch": "^0.6.1", + "less-plugin-clean-css": "^1.5.1" + } +}