2014-10-02 13:36:05 +04:00
|
|
|
module.exports = function(grunt) {
|
2014-11-26 15:28:22 +03:00
|
|
|
"use strict";
|
2014-10-02 13:36:05 +04:00
|
|
|
|
2014-11-26 15:28:22 +03:00
|
|
|
require("load-grunt-tasks")(grunt);
|
2014-10-05 11:32:48 +04:00
|
|
|
|
2014-11-26 15:28:22 +03:00
|
|
|
grunt.initConfig({
|
2014-10-03 23:15:31 +04:00
|
|
|
|
2014-12-04 15:17:45 +03:00
|
|
|
|
|
|
|
// Compile less to .css
|
|
|
|
// Compile less to .min.css
|
|
|
|
// Create source maps of both
|
2014-11-26 15:28:22 +03:00
|
|
|
less: {
|
|
|
|
material: {
|
|
|
|
options: {
|
|
|
|
paths: ["less"],
|
|
|
|
sourceMap: true,
|
|
|
|
sourceMapRootpath: "/",
|
|
|
|
sourceMapFilename: "dist/css/material.css.map",
|
|
|
|
sourceMapURL: "material.css.map"
|
2014-10-03 23:15:31 +04:00
|
|
|
},
|
2014-11-26 15:28:22 +03:00
|
|
|
files: {
|
|
|
|
"dist/css/material.css": "less/material.less",
|
|
|
|
}
|
|
|
|
},
|
2014-12-04 15:17:45 +03:00
|
|
|
materialwfont: {
|
2014-11-26 15:28:22 +03:00
|
|
|
options: {
|
|
|
|
paths: ["less"],
|
|
|
|
sourceMap: true,
|
|
|
|
sourceMapRootpath: "/",
|
|
|
|
sourceMapFilename: "dist/css/material-wfont.css.map",
|
2014-12-04 15:17:45 +03:00
|
|
|
sourceMapURL: "material-wfont.css.map",
|
|
|
|
outputSourceFiles: true
|
2014-10-03 23:15:31 +04:00
|
|
|
},
|
2014-11-26 15:28:22 +03:00
|
|
|
files: {
|
|
|
|
"dist/css/material-wfont.css": "less/material-wfont.less",
|
|
|
|
}
|
|
|
|
},
|
|
|
|
ripples: {
|
|
|
|
options: {
|
|
|
|
paths: ["less"],
|
|
|
|
sourceMap: true,
|
|
|
|
sourceMapRootpath: "/",
|
|
|
|
sourceMapFilename: "dist/css/ripples.css.map",
|
2014-12-04 15:17:45 +03:00
|
|
|
sourceMapURL: "ripples.css.map",
|
|
|
|
outputSourceFiles: true
|
2014-10-03 23:15:31 +04:00
|
|
|
},
|
2014-11-26 15:28:22 +03:00
|
|
|
files: {
|
|
|
|
"dist/css/ripples.css": "less/ripples.less",
|
2014-10-02 13:36:05 +04:00
|
|
|
}
|
2014-11-26 15:28:22 +03:00
|
|
|
}
|
|
|
|
},
|
|
|
|
|
2014-12-04 15:17:45 +03:00
|
|
|
// Autoprefix .css and edit its source map
|
|
|
|
// Autoprefix .min.css an edit its source map
|
2014-11-26 15:28:22 +03:00
|
|
|
autoprefixer: {
|
|
|
|
options: {
|
2014-12-04 15:17:45 +03:00
|
|
|
map: true,
|
2014-11-26 15:28:22 +03:00
|
|
|
browsers: ["last 3 versions", "ie 8", "ie 9", "ie 10", "ie 11"]
|
|
|
|
},
|
2014-12-04 15:17:45 +03:00
|
|
|
material: {
|
2014-11-26 15:28:22 +03:00
|
|
|
files: {
|
|
|
|
"dist/css/material.css": "dist/css/material.css",
|
2014-12-04 15:17:45 +03:00
|
|
|
"dist/css/material.min.css": "dist/css/material.min.css"
|
|
|
|
}
|
|
|
|
},
|
|
|
|
materialwfont: {
|
|
|
|
files: {
|
2014-11-26 15:28:22 +03:00
|
|
|
"dist/css/material-wfont.css": "dist/css/material-wfont.css",
|
2014-12-04 15:17:45 +03:00
|
|
|
"dist/css/material-wfont.min.css": "dist/css/material-wfont.min.css"
|
2014-11-26 15:28:22 +03:00
|
|
|
}
|
|
|
|
},
|
2014-12-04 15:17:45 +03:00
|
|
|
ripples: {
|
2014-11-26 15:28:22 +03:00
|
|
|
files: {
|
2014-12-04 15:17:45 +03:00
|
|
|
"dist/css/ripples.css": "dist/css/ripples.css",
|
|
|
|
"dist/css/ripples.min.css": "dist/css/ripples.min.css"
|
2014-11-26 15:28:22 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
2014-12-04 15:30:23 +03:00
|
|
|
// Minify CSS and adapt maps
|
|
|
|
csswring: {
|
|
|
|
material: {
|
|
|
|
src: "dist/css/material.css",
|
|
|
|
dest: "dist/css/material.min.css"
|
|
|
|
},
|
|
|
|
materialwfont: {
|
|
|
|
src: "dist/css/material-wfont.css",
|
|
|
|
dest: "dist/css/material-wfont.min.css"
|
|
|
|
},
|
|
|
|
ripples: {
|
|
|
|
src: "dist/css/ripples.css",
|
|
|
|
dest: "dist/css/ripples.min.css"
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
2014-12-04 15:17:45 +03:00
|
|
|
// Copy .js to dist/js/ folder
|
2014-11-26 15:28:22 +03:00
|
|
|
copy: {
|
2014-12-04 15:17:45 +03:00
|
|
|
material: {
|
|
|
|
src: "scripts/material.js",
|
|
|
|
dest: "dist/js/material.js"
|
|
|
|
},
|
|
|
|
ripples: {
|
|
|
|
src: "scripts/ripples.js",
|
|
|
|
dest: "dist/js/ripples.js"
|
2014-11-26 15:28:22 +03:00
|
|
|
},
|
2014-12-04 15:17:45 +03:00
|
|
|
fonts: {
|
2014-11-26 15:28:22 +03:00
|
|
|
expand: true,
|
|
|
|
cwd: "fonts/",
|
|
|
|
src: "**",
|
|
|
|
dest: "dist/fonts/",
|
|
|
|
flatten: true,
|
|
|
|
filter: "isFile"
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
2014-12-04 15:17:45 +03:00
|
|
|
// Compile .js to .min.js
|
|
|
|
uglify: {
|
|
|
|
options: {
|
|
|
|
sourceMap: true
|
|
|
|
},
|
|
|
|
material: {
|
|
|
|
files: {
|
|
|
|
"dist/js/material.min.js": "dist/js/material.js"
|
|
|
|
}
|
|
|
|
},
|
|
|
|
ripples: {
|
|
|
|
files: {
|
|
|
|
"dist/js/ripples.min.js": "dist/js/ripples.js"
|
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
2014-12-05 11:25:06 +03:00
|
|
|
connect: {
|
|
|
|
options: {
|
|
|
|
port: 8040,
|
|
|
|
hostname: "localhost",
|
|
|
|
livereload: 35729
|
|
|
|
|
|
|
|
},
|
|
|
|
livereload: {
|
|
|
|
options: {
|
|
|
|
open: true,
|
|
|
|
base: "."
|
|
|
|
}
|
|
|
|
},
|
|
|
|
test: {
|
|
|
|
options: {
|
|
|
|
port: 8041,
|
|
|
|
open: "http://localhost:8041/_SpecRunner.html",
|
|
|
|
base: "."
|
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
2014-11-26 15:28:22 +03:00
|
|
|
jasmine: {
|
|
|
|
scripts: "scripts/**/*.js",
|
|
|
|
options: {
|
|
|
|
build: true,
|
|
|
|
specs: "test/*Spec.js",
|
|
|
|
helpers: "test/*Helper.js",
|
|
|
|
vendor: [
|
|
|
|
"https://code.jquery.com/jquery-1.10.2.min.js",
|
|
|
|
"https://maxcdn.bootstrapcdn.com/bootstrap/3.2.0/js/bootstrap.min.js"
|
|
|
|
]
|
|
|
|
}
|
|
|
|
},
|
|
|
|
jshint: {
|
|
|
|
options: {
|
|
|
|
jshintrc: ".jshintrc",
|
|
|
|
reporter: require("jshint-stylish")
|
|
|
|
},
|
|
|
|
all: [
|
|
|
|
"Gruntfile.js",
|
|
|
|
"scripts/**/*.js",
|
|
|
|
"template/**/*.js",
|
|
|
|
"!template/**/*.min.js"
|
|
|
|
],
|
|
|
|
test: {
|
|
|
|
options: {
|
|
|
|
jshintrc: "test/.jshintrc",
|
|
|
|
src: ["test/**/*.js"]
|
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
|
|
|
watch: {
|
|
|
|
js: {
|
|
|
|
files: ["Gruntfile.js", "scripts/**/*.js", "template/**/*.js"],
|
|
|
|
tasks: ["newer:jshint:all"]
|
|
|
|
},
|
|
|
|
jsTest: {
|
|
|
|
files: ["test/**/*.js"],
|
|
|
|
tasks: ["newer:jshint:test", "jasmine"]
|
|
|
|
},
|
|
|
|
less: {
|
|
|
|
files:["less/**/*.less"],
|
|
|
|
tasks: ["default"]
|
|
|
|
},
|
|
|
|
livereload: {
|
|
|
|
options: {
|
|
|
|
livereload: "<%= connect.options.livereload %>"
|
|
|
|
},
|
|
|
|
files: [
|
|
|
|
"index.html",
|
|
|
|
"dist/css/**/*.css",
|
|
|
|
"**/*.{png,jpg,jpeg,gif,webp,svg}"
|
|
|
|
]
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
2014-12-04 15:17:45 +03:00
|
|
|
grunt.registerTask("default", ["material", "ripples"]);
|
2014-11-26 15:28:22 +03:00
|
|
|
|
2014-12-04 15:17:45 +03:00
|
|
|
grunt.registerTask("material", [
|
2014-12-04 16:00:01 +03:00
|
|
|
"material:less",
|
|
|
|
"material:js"
|
2014-12-04 15:17:45 +03:00
|
|
|
]);
|
|
|
|
grunt.registerTask("material:less", [
|
|
|
|
"less:material",
|
|
|
|
"less:materialwfont",
|
2014-12-04 15:30:23 +03:00
|
|
|
"csswring:material",
|
|
|
|
"csswring:materialwfont",
|
2014-12-04 15:17:45 +03:00
|
|
|
"autoprefixer:material",
|
2014-12-04 17:34:10 +03:00
|
|
|
"autoprefixer:materialwfont"
|
2014-12-04 15:17:45 +03:00
|
|
|
]);
|
|
|
|
grunt.registerTask("material:js", [
|
|
|
|
"copy:material",
|
|
|
|
"uglify:material"
|
|
|
|
]);
|
|
|
|
|
|
|
|
grunt.registerTask("ripples", [
|
2014-12-04 16:00:01 +03:00
|
|
|
"ripples:less",
|
2014-12-04 17:34:10 +03:00
|
|
|
"ripples:js"
|
2014-12-04 15:17:45 +03:00
|
|
|
]);
|
|
|
|
grunt.registerTask("ripples:less", [
|
|
|
|
"less:ripples",
|
2014-12-04 15:30:23 +03:00
|
|
|
"csswring:ripples",
|
2014-12-04 17:34:10 +03:00
|
|
|
"autoprefixer:ripples"
|
2014-12-04 15:17:45 +03:00
|
|
|
]);
|
|
|
|
grunt.registerTask("ripples:js", [
|
|
|
|
"copy:ripples",
|
2014-12-04 17:34:10 +03:00
|
|
|
"uglify:ripples"
|
2014-12-04 15:17:45 +03:00
|
|
|
]);
|
2014-11-26 15:28:22 +03:00
|
|
|
|
|
|
|
grunt.registerTask("build", function(target) {
|
|
|
|
var buildType = "default";
|
|
|
|
if (target && target === "scss") {
|
|
|
|
buildType = "scss";
|
|
|
|
}
|
|
|
|
grunt.task.run(["newer:jshint", "jasmine:scripts", buildType]);
|
|
|
|
});
|
|
|
|
|
|
|
|
grunt.registerTask("test", [
|
|
|
|
"jasmine:scripts:build",
|
|
|
|
"connect:test:keepalive"
|
|
|
|
]);
|
|
|
|
|
|
|
|
grunt.registerTask("serve", function(target){
|
2014-12-04 15:17:45 +03:00
|
|
|
var buildTarget = "material:less";
|
2014-11-26 15:28:22 +03:00
|
|
|
if(target && target === "scss") {
|
|
|
|
buildTarget = "scss";
|
|
|
|
}
|
|
|
|
grunt.task.run([
|
|
|
|
"build:"+ buildTarget,
|
|
|
|
"connect:livereload",
|
|
|
|
"watch"
|
2014-10-03 23:15:31 +04:00
|
|
|
]);
|
2014-11-26 15:28:22 +03:00
|
|
|
});
|
2014-10-03 23:15:31 +04:00
|
|
|
|
2014-11-26 15:28:22 +03:00
|
|
|
grunt.registerTask("cibuild",["newer:jshint", "jasmine:scripts"]);
|
2014-10-02 13:36:05 +04:00
|
|
|
};
|