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
|
|
|
|
2015-11-02 22:42:29 +03:00
|
|
|
// Convert from less to sass
|
2015-11-02 23:39:13 +03:00
|
|
|
lessToSass: {
|
2015-11-02 22:42:29 +03:00
|
|
|
convert: {
|
|
|
|
files: [{
|
|
|
|
expand: true,
|
|
|
|
cwd: 'less',
|
2015-11-03 03:29:40 +03:00
|
|
|
src: ['*.less', '!_mixins.less', '!_mixins-fullpalette.less'],
|
2015-11-02 22:42:29 +03:00
|
|
|
ext: '.scss',
|
2015-11-02 23:39:13 +03:00
|
|
|
dest: 'sass'
|
2015-11-03 04:17:00 +03:00
|
|
|
}],
|
|
|
|
options: {
|
|
|
|
replacements: [
|
2015-11-03 21:33:54 +03:00
|
|
|
// bad conversions of shadow-z-* to @include instead of @extend
|
|
|
|
{ // https://regex101.com/r/bF2iJ2/1
|
|
|
|
pattern: /@include shadow-z-(\d+)((?:-hover)?)\(\);/gi,
|
|
|
|
replacement: '@extend .shadow-z-$1$2;',
|
2015-11-03 04:17:00 +03:00
|
|
|
order: 2
|
|
|
|
},
|
2015-11-03 21:33:54 +03:00
|
|
|
// bad conversions to @include instead of @extend
|
|
|
|
{
|
2015-11-03 04:17:00 +03:00
|
|
|
pattern: /@include (foo1|foo2)\(\);/gi,
|
|
|
|
replacement: '@extend .$1;',
|
|
|
|
order: 2
|
2015-11-03 20:28:56 +03:00
|
|
|
},
|
|
|
|
|
|
|
|
// button variations mixin replacement(s)
|
2015-11-03 21:28:56 +03:00
|
|
|
{ // Multi-line replacement - https://regex101.com/r/qD9qB8/2
|
2015-11-03 21:12:20 +03:00
|
|
|
pattern: /.generic-variations\(unquote\(("[^"]+")\), (\$[\s\S]+?(?!\r|\n)), {$\n[\s\S]+?(?!\r|\n)contrast[\s\S]+?(?!\r|\n)(\d+)[\s\S]+?(?!\r|\n)}\);$\n/mg,
|
|
|
|
replacement: '@include button-variations(unquote($1), $2, $3%);\n',
|
|
|
|
order: 20
|
2015-11-03 21:28:56 +03:00
|
|
|
},
|
|
|
|
|
|
|
|
// background-color generic-variations
|
|
|
|
{ // Multi-line replacement - https://regex101.com/r/cW6pH8/2
|
|
|
|
pattern: /.generic-variations\(unquote\(("[^"]+")\), (\$[\s\S]+?(?!\r|\n)), {$\n[\s\S]+?(?!\r|\n)background-color[\s\S]+?(?!\r|\n)(\(\d+\/\d+\))[\s\S]+?(?!\r|\n)}\);$\n/mg,
|
|
|
|
replacement: '@include bg-color-variations(unquote($1), $2, $3);\n',
|
|
|
|
order: 21
|
2015-11-04 23:34:47 +03:00
|
|
|
},
|
2015-11-03 04:17:00 +03:00
|
|
|
|
2015-11-04 23:34:47 +03:00
|
|
|
// bg-box-shadow generic-variations
|
|
|
|
{ // Multi-line replacement - https://regex101.com/r/jW8kR1/1
|
|
|
|
pattern: /.generic-variations\(unquote\(("[^"]+")\), (\$[\s\S]+?(?!\r|\n)), {$\n[\s\S]+?(?!\r|\n)box-shadow[\s\S]+?(?!\r|\n)[\s\S]+?(?!\r|\n)}\);$\n/mg,
|
|
|
|
replacement: '@include bg-box-shadow-variations(unquote($1), $2);\n',
|
|
|
|
order: 22
|
2015-11-04 23:41:37 +03:00
|
|
|
},
|
|
|
|
|
|
|
|
// bg-img generic-variations
|
|
|
|
{ // Multi-line replacement - https://regex101.com/r/aP2hH2/1
|
|
|
|
pattern: /.generic-variations\(unquote\(("[^"]+")\), (\$[\s\S]+?(?!\r|\n)), {$\n[\s\S]+?(?!\r|\n)background-image[\s\S]+?(?!\r|\n)[\s\S]+?(?!\r|\n)}\);$\n/mg,
|
|
|
|
replacement: '@include bg-img-variations(unquote($1), $2);\n',
|
|
|
|
order: 23
|
|
|
|
} ]
|
2015-11-03 04:17:00 +03:00
|
|
|
}
|
2015-11-02 22:42:29 +03:00
|
|
|
}
|
|
|
|
},
|
2014-12-04 15:17:45 +03:00
|
|
|
|
2015-11-03 02:55:59 +03:00
|
|
|
// Test compile sass
|
|
|
|
sass: {
|
|
|
|
compile: {
|
|
|
|
files: [{
|
|
|
|
expand: true,
|
|
|
|
cwd: 'sass',
|
|
|
|
//src: ['material.scss', 'material-fullpalette.scss', 'ripples.scss', 'roboto.scss'],
|
|
|
|
src: ['material.scss'],
|
|
|
|
dest: 'tmp/sass/compiled',
|
|
|
|
ext: '.css'
|
|
|
|
}]
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
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",
|
|
|
|
}
|
|
|
|
},
|
2015-03-09 19:10:44 +03:00
|
|
|
materialfullpalette: {
|
2014-11-26 15:28:22 +03:00
|
|
|
options: {
|
|
|
|
paths: ["less"],
|
|
|
|
sourceMap: true,
|
|
|
|
sourceMapRootpath: "/",
|
2015-03-09 19:10:44 +03:00
|
|
|
sourceMapFilename: "dist/css/material-fullpalette.css.map",
|
|
|
|
sourceMapURL: "material-fullpalette.css.map",
|
2014-12-04 15:17:45 +03:00
|
|
|
outputSourceFiles: true
|
2014-10-03 23:15:31 +04:00
|
|
|
},
|
2014-11-26 15:28:22 +03:00
|
|
|
files: {
|
2015-03-09 19:10:44 +03:00
|
|
|
"dist/css/material-fullpalette.css": "less/material-fullpalette.less",
|
|
|
|
}
|
|
|
|
},
|
|
|
|
roboto: {
|
|
|
|
options: {
|
|
|
|
paths: ["less"],
|
|
|
|
sourceMap: true,
|
|
|
|
sourceMapRootpath: "/",
|
|
|
|
sourceMapFilename: "dist/css/roboto.css.map",
|
|
|
|
sourceMapURL: "roboto.css.map",
|
|
|
|
outputSourceFiles: true
|
|
|
|
},
|
|
|
|
files: {
|
|
|
|
"dist/css/roboto.css": "less/roboto.less",
|
2014-11-26 15:28:22 +03:00
|
|
|
}
|
|
|
|
},
|
|
|
|
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"
|
|
|
|
}
|
|
|
|
},
|
2015-03-09 19:10:44 +03:00
|
|
|
materialfullpalette: {
|
|
|
|
files: {
|
|
|
|
"dist/css/material-fullpalette.css": "dist/css/material-fullpalette.css",
|
|
|
|
"dist/css/material-fullpalette.min.css": "dist/css/material-fullpalette.min.css"
|
|
|
|
}
|
|
|
|
},
|
|
|
|
roboto: {
|
2014-12-04 15:17:45 +03:00
|
|
|
files: {
|
2015-03-09 19:10:44 +03:00
|
|
|
"dist/css/roboto.css": "dist/css/roboto.css",
|
|
|
|
"dist/css/roboto.min.css": "dist/css/roboto.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"
|
|
|
|
},
|
2015-03-09 19:10:44 +03:00
|
|
|
materialfullpalette: {
|
|
|
|
src: "dist/css/material-fullpalette.css",
|
|
|
|
dest: "dist/css/material-fullpalette.min.css"
|
|
|
|
},
|
|
|
|
roboto: {
|
|
|
|
src: "dist/css/roboto.css",
|
|
|
|
dest: "dist/css/roboto.min.css"
|
2014-12-04 15:30:23 +03:00
|
|
|
},
|
|
|
|
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"],
|
2015-03-11 18:45:01 +03:00
|
|
|
tasks: ["material:less"]
|
2014-11-26 15:28:22 +03:00
|
|
|
},
|
|
|
|
livereload: {
|
|
|
|
options: {
|
|
|
|
livereload: "<%= connect.options.livereload %>"
|
|
|
|
},
|
|
|
|
files: [
|
|
|
|
"index.html",
|
|
|
|
"dist/css/**/*.css",
|
2015-03-04 23:47:53 +03:00
|
|
|
"demo/**/*.{png,jpg,jpeg,gif,webp,svg}"
|
2014-11-26 15:28:22 +03:00
|
|
|
]
|
|
|
|
}
|
2014-12-15 18:16:33 +03:00
|
|
|
},
|
|
|
|
exec: {
|
|
|
|
"meteor-init": {
|
|
|
|
command: [
|
|
|
|
// Make sure Meteor is installed, per https://meteor.com/install.
|
|
|
|
// The curl'ed script is safe; takes 2 minutes to read source & check.
|
|
|
|
"type meteor >/dev/null 2>&1 || { curl https://install.meteor.com/ | sh; }",
|
|
|
|
// Meteor expects package.js to be in the root directory of
|
|
|
|
// the checkout, so copy it there temporarily
|
|
|
|
"cp meteor/package.js ."
|
|
|
|
].join(";")
|
|
|
|
},
|
|
|
|
"meteor-cleanup": {
|
|
|
|
// remove build files and package.js
|
|
|
|
command: "rm -rf .build.* versions.json package.js"
|
|
|
|
},
|
|
|
|
"meteor-test": {
|
|
|
|
command: "node_modules/.bin/spacejam --mongo-url mongodb:// test-packages ./"
|
|
|
|
},
|
|
|
|
"meteor-publish": {
|
2014-12-16 05:09:20 +03:00
|
|
|
command: [
|
|
|
|
"ALL_EXIT_CODE=0; for PACKAGE_FILE in meteor/package*.js",
|
|
|
|
"do cp $PACKAGE_FILE ./package.js && meteor publish $@",
|
|
|
|
"ALL_EXIT_CODE=$(echo $ALL_EXIT_CODE + $? | bc); done",
|
|
|
|
"exit $ALL_EXIT_CODE"
|
|
|
|
].join(";")
|
2014-12-15 18:16:33 +03:00
|
|
|
}
|
2014-11-26 15:28:22 +03:00
|
|
|
}
|
2014-12-15 18:16:33 +03:00
|
|
|
|
2014-11-26 15:28:22 +03:00
|
|
|
});
|
|
|
|
|
2015-11-02 23:39:13 +03:00
|
|
|
grunt.loadNpmTasks('grunt-less-to-sass');
|
|
|
|
|
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
|
|
|
]);
|
2015-11-02 22:42:29 +03:00
|
|
|
|
|
|
|
grunt.registerTask("material:sass", [
|
2015-11-03 02:55:59 +03:00
|
|
|
"lessToSass:convert",
|
|
|
|
"sass:compile"
|
2015-11-02 22:42:29 +03:00
|
|
|
]);
|
|
|
|
|
2014-12-04 15:17:45 +03:00
|
|
|
grunt.registerTask("material:less", [
|
|
|
|
"less:material",
|
2015-03-09 19:10:44 +03:00
|
|
|
"less:materialfullpalette",
|
|
|
|
"less:roboto",
|
2014-12-04 15:30:23 +03:00
|
|
|
"csswring:material",
|
2015-03-09 19:10:44 +03:00
|
|
|
"csswring:materialfullpalette",
|
|
|
|
"csswring:roboto",
|
2014-12-04 15:17:45 +03:00
|
|
|
"autoprefixer:material",
|
2015-03-09 19:10:44 +03:00
|
|
|
"autoprefixer:materialfullpalette",
|
|
|
|
"autoprefixer:roboto"
|
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
|
|
|
|
2015-03-16 17:45:18 +03:00
|
|
|
grunt.registerTask("build", function() {
|
|
|
|
grunt.task.run(["newer:jshint", "default"]);
|
2014-11-26 15:28:22 +03:00
|
|
|
});
|
|
|
|
|
|
|
|
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-12-15 18:16:33 +03:00
|
|
|
// Meteor tasks
|
|
|
|
grunt.registerTask("meteor-test", ["exec:meteor-init", "exec:meteor-test", "exec:meteor-cleanup"]);
|
|
|
|
grunt.registerTask("meteor-publish", ["exec:meteor-init", "exec:meteor-publish", "exec:meteor-cleanup"]);
|
|
|
|
grunt.registerTask("meteor", ["exec:meteor-init", "exec:meteor-test", "exec:meteor-publish", "exec:meteor-cleanup"]);
|
|
|
|
|
2015-03-17 18:05:03 +03:00
|
|
|
grunt.registerTask("cibuild", ["newer:jshint", "meteor-test"]);
|
2014-12-15 18:16:33 +03:00
|
|
|
|
2014-10-02 13:36:05 +04:00
|
|
|
};
|