2014-06-09 06:02:39 -07:00
|
|
|
/**
|
|
|
|
*
|
2015-02-16 06:06:43 -08:00
|
|
|
* Material Design Lite
|
2015-01-06 05:36:47 -08:00
|
|
|
* Copyright 2015 Google Inc. All rights reserved.
|
2014-06-09 06:02:39 -07:00
|
|
|
*
|
2014-06-09 01:56:26 -07:00
|
|
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
* you may not use this file except in compliance with the License.
|
|
|
|
* You may obtain a copy of the License at
|
2014-06-09 06:02:39 -07:00
|
|
|
*
|
2014-10-22 06:14:09 -07:00
|
|
|
* https://www.apache.org/licenses/LICENSE-2.0
|
2014-06-09 06:02:39 -07:00
|
|
|
*
|
2014-06-09 01:56:26 -07:00
|
|
|
* Unless required by applicable law or agreed to in writing, software
|
|
|
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
* See the License for the specific language governing permissions and
|
|
|
|
* limitations under the License
|
2014-06-09 06:02:39 -07:00
|
|
|
*
|
2014-06-09 01:56:26 -07:00
|
|
|
*/
|
2014-06-09 06:02:39 -07:00
|
|
|
|
2014-04-17 05:02:38 -07:00
|
|
|
'use strict';
|
2014-06-19 05:14:21 -07:00
|
|
|
|
|
|
|
// Include Gulp & Tools We'll Use
|
2014-04-17 05:02:38 -07:00
|
|
|
var gulp = require('gulp');
|
2015-06-23 09:22:22 -07:00
|
|
|
var fs = require('fs');
|
|
|
|
var merge = require('merge-stream');
|
2014-06-07 10:38:49 -07:00
|
|
|
var $ = require('gulp-load-plugins')();
|
2014-06-21 13:32:57 -07:00
|
|
|
var del = require('del');
|
2014-06-18 18:37:49 -07:00
|
|
|
var runSequence = require('run-sequence');
|
2014-05-06 05:47:36 -07:00
|
|
|
var browserSync = require('browser-sync');
|
2015-07-05 11:17:45 -07:00
|
|
|
var codeFiles = '';
|
2014-05-06 05:47:36 -07:00
|
|
|
var reload = browserSync.reload;
|
2015-01-29 07:26:23 -08:00
|
|
|
var path = require('path');
|
2015-02-04 02:14:57 -08:00
|
|
|
var pkg = require('./package.json');
|
2015-04-01 04:54:06 -07:00
|
|
|
var through = require('through2');
|
|
|
|
var swig = require('swig');
|
2015-07-01 06:40:42 -07:00
|
|
|
var MaterialCustomizer = require('./docs/_assets/customizer.js');
|
2015-07-03 02:53:36 -07:00
|
|
|
var hostedLibsUrlPrefix = 'https://storage.googleapis.com/code.getmdl.io';
|
2015-06-25 03:34:00 -07:00
|
|
|
var bucketProd = 'gs://www.getmdl.io';
|
|
|
|
var bucketStaging = 'gs://mdl-staging';
|
|
|
|
var bucketCode = 'gs://code.getmdl.io';
|
2015-02-04 02:14:57 -08:00
|
|
|
var banner = ['/**',
|
|
|
|
' * <%= pkg.name %> - <%= pkg.description %>',
|
|
|
|
' * @version v<%= pkg.version %>',
|
2015-03-17 03:08:30 -07:00
|
|
|
' * @license <%= pkg.license.type %>',
|
2015-07-05 06:57:40 -07:00
|
|
|
' * @copyright 2015 Google, Inc.',
|
|
|
|
' * @link <%= pkg.homepage %>',
|
2015-02-04 02:14:57 -08:00
|
|
|
' */',
|
|
|
|
''].join('\n');
|
|
|
|
|
|
|
|
var AUTOPREFIXER_BROWSERS = [
|
|
|
|
'ie >= 10',
|
|
|
|
'ie_mob >= 10',
|
|
|
|
'ff >= 30',
|
|
|
|
'chrome >= 34',
|
|
|
|
'safari >= 7',
|
|
|
|
'opera >= 23',
|
|
|
|
'ios >= 7',
|
|
|
|
'android >= 4.4',
|
|
|
|
'bb >= 10'
|
|
|
|
];
|
2014-04-17 05:02:38 -07:00
|
|
|
|
2015-04-01 04:54:06 -07:00
|
|
|
// ***** Development tasks ****** //
|
|
|
|
|
2014-06-19 05:14:21 -07:00
|
|
|
// Lint JavaScript
|
2015-02-04 02:14:57 -08:00
|
|
|
gulp.task('jshint', function () {
|
2015-06-25 03:34:00 -07:00
|
|
|
return gulp.src(['src/**/*.js' , 'gulpfile.js'])
|
2014-06-26 12:32:04 -07:00
|
|
|
.pipe(reload({stream: true, once: true}))
|
2015-02-10 05:20:01 -08:00
|
|
|
.pipe($.jshint())
|
|
|
|
.pipe($.jshint.reporter('jshint-stylish'))
|
|
|
|
.pipe($.if(!browserSync.active, $.jshint.reporter('fail')));
|
2014-06-19 05:14:21 -07:00
|
|
|
});
|
2014-05-07 02:33:42 -07:00
|
|
|
|
2015-06-15 02:26:18 -07:00
|
|
|
// Lint JavaScript code style
|
|
|
|
gulp.task('jscs', function () {
|
2015-06-25 03:34:00 -07:00
|
|
|
return gulp.src(['src/**/*.js' , 'gulpfile.js'])
|
2015-06-15 02:26:18 -07:00
|
|
|
.pipe(reload({stream: true, once: true}))
|
|
|
|
.pipe($.jscs())
|
|
|
|
.pipe($.if(!browserSync.active, $.jshint.reporter('fail')));
|
|
|
|
});
|
|
|
|
|
2015-04-01 04:54:06 -07:00
|
|
|
// ***** Production build tasks ****** //
|
|
|
|
|
2014-06-19 05:14:21 -07:00
|
|
|
// Optimize Images
|
2015-02-04 02:14:57 -08:00
|
|
|
// TODO: Update image paths in final CSS to match root/images
|
|
|
|
gulp.task('images', function () {
|
|
|
|
return gulp.src('src/**/*.{svg,png,jpg}')
|
2015-02-24 01:11:04 -08:00
|
|
|
.pipe($.flatten())
|
2014-06-20 08:20:44 -07:00
|
|
|
.pipe($.cache($.imagemin({
|
|
|
|
progressive: true,
|
|
|
|
interlaced: true
|
|
|
|
})))
|
2015-05-06 06:39:10 -07:00
|
|
|
.pipe(gulp.dest('dist/images'))
|
2014-06-20 08:20:44 -07:00
|
|
|
.pipe($.size({title: 'images'}));
|
2014-06-19 05:14:21 -07:00
|
|
|
});
|
|
|
|
|
2015-02-04 02:14:57 -08:00
|
|
|
// Compile and Automatically Prefix Stylesheets (dev)
|
2015-06-01 07:15:55 -07:00
|
|
|
gulp.task('styles:dev', function () {
|
2015-02-04 02:14:57 -08:00
|
|
|
return gulp.src([
|
2015-03-20 08:36:16 -07:00
|
|
|
'src/**/*.scss'
|
2015-02-04 02:14:57 -08:00
|
|
|
])
|
|
|
|
.pipe($.sass({
|
|
|
|
precision: 10,
|
|
|
|
onError: console.error.bind(console, 'Sass error:')
|
|
|
|
}))
|
2015-05-07 19:01:05 -07:00
|
|
|
.pipe($.cssInlineImages({
|
|
|
|
webRoot: 'src'
|
2015-04-16 04:55:04 -07:00
|
|
|
}))
|
2015-02-04 02:14:57 -08:00
|
|
|
.pipe($.autoprefixer(AUTOPREFIXER_BROWSERS))
|
2015-02-05 04:39:43 -08:00
|
|
|
.pipe(gulp.dest('.tmp/styles'))
|
2015-02-04 02:14:57 -08:00
|
|
|
.pipe($.size({title: 'styles'}));
|
2014-07-08 07:53:00 -07:00
|
|
|
});
|
|
|
|
|
2015-03-18 11:31:44 -07:00
|
|
|
// Compile and Automatically Prefix Stylesheet Templates (production)
|
|
|
|
gulp.task('styletemplates', function () {
|
|
|
|
// For best performance, don't add Sass partials to `gulp.src`
|
|
|
|
return gulp.src([
|
|
|
|
'src/template.scss'
|
|
|
|
])
|
|
|
|
// Generate Source Maps
|
|
|
|
.pipe ($.sourcemaps.init())
|
|
|
|
.pipe($.sass({
|
|
|
|
precision: 10,
|
|
|
|
onError: console.error.bind(console, 'Sass error:')
|
|
|
|
}))
|
2015-05-07 19:01:05 -07:00
|
|
|
.pipe($.cssInlineImages({
|
|
|
|
webRoot: 'src'
|
2015-04-16 04:55:04 -07:00
|
|
|
}))
|
2015-03-18 11:31:44 -07:00
|
|
|
.pipe($.autoprefixer(AUTOPREFIXER_BROWSERS))
|
|
|
|
.pipe(gulp.dest('.tmp'))
|
|
|
|
// Concatenate Styles
|
|
|
|
.pipe($.concat('material.css.template'))
|
2015-05-06 06:25:08 -07:00
|
|
|
.pipe(gulp.dest('./dist'))
|
2015-03-18 11:31:44 -07:00
|
|
|
// Minify Styles
|
2015-03-19 05:47:21 -07:00
|
|
|
.pipe($.if('*.css.template', $.csso()))
|
2015-03-18 11:31:44 -07:00
|
|
|
.pipe($.concat('material.min.css.template'))
|
2015-06-12 15:55:41 -07:00
|
|
|
.pipe($.header(banner, {pkg: pkg}))
|
2015-04-08 12:02:29 -07:00
|
|
|
.pipe($.sourcemaps.write('./'))
|
2015-05-06 06:25:08 -07:00
|
|
|
.pipe(gulp.dest('./dist'))
|
2015-03-18 11:31:44 -07:00
|
|
|
.pipe($.size({title: 'styles'}));
|
|
|
|
});
|
|
|
|
|
2015-02-04 02:14:57 -08:00
|
|
|
// Compile and Automatically Prefix Stylesheets (production)
|
2015-03-18 11:31:44 -07:00
|
|
|
gulp.task('styles', ['styletemplates'], function () {
|
2014-07-29 16:25:19 -07:00
|
|
|
// For best performance, don't add Sass partials to `gulp.src`
|
|
|
|
return gulp.src([
|
2015-02-04 02:14:57 -08:00
|
|
|
'src/styleguide.scss'
|
2014-10-14 08:19:35 -07:00
|
|
|
])
|
2015-02-24 06:21:47 -08:00
|
|
|
// Generate Source Maps
|
|
|
|
.pipe ($.sourcemaps.init())
|
2014-11-25 03:22:05 -08:00
|
|
|
.pipe($.sass({
|
2015-01-07 05:50:02 -08:00
|
|
|
precision: 10,
|
|
|
|
onError: console.error.bind(console, 'Sass error:')
|
|
|
|
}))
|
2015-05-07 19:01:05 -07:00
|
|
|
.pipe($.cssInlineImages({
|
|
|
|
webRoot: 'src'
|
2015-04-16 04:55:04 -07:00
|
|
|
}))
|
2014-07-04 04:35:14 -07:00
|
|
|
.pipe($.autoprefixer(AUTOPREFIXER_BROWSERS))
|
2014-09-03 03:47:19 -07:00
|
|
|
.pipe(gulp.dest('.tmp'))
|
2015-02-04 02:14:57 -08:00
|
|
|
// Concatenate Styles
|
|
|
|
.pipe($.concat('material.css'))
|
|
|
|
.pipe($.header(banner, {pkg: pkg}))
|
2015-05-06 06:25:08 -07:00
|
|
|
.pipe(gulp.dest('./dist'))
|
2015-02-04 02:14:57 -08:00
|
|
|
// Minify Styles
|
2014-08-28 09:13:09 -07:00
|
|
|
.pipe($.if('*.css', $.csso()))
|
2015-02-04 02:14:57 -08:00
|
|
|
.pipe($.concat('material.min.css'))
|
2015-06-12 15:55:41 -07:00
|
|
|
.pipe($.header(banner, {pkg: pkg}))
|
2015-02-24 06:21:47 -08:00
|
|
|
.pipe($.sourcemaps.write('./'))
|
2015-05-06 06:25:08 -07:00
|
|
|
.pipe(gulp.dest('./dist'))
|
2014-07-29 16:25:19 -07:00
|
|
|
.pipe($.size({title: 'styles'}));
|
2014-06-18 18:37:49 -07:00
|
|
|
});
|
2014-06-18 12:58:06 -07:00
|
|
|
|
2015-06-15 09:24:52 -07:00
|
|
|
// Only generate CSS styles for the MDL grid
|
|
|
|
gulp.task('styles-grid', function () {
|
|
|
|
return gulp.src(['src/material-design-lite-grid.scss'])
|
|
|
|
.pipe($.sass({
|
|
|
|
precision: 10,
|
|
|
|
onError: console.error.bind(console, 'Sass error:')
|
|
|
|
}))
|
|
|
|
.pipe($.autoprefixer(AUTOPREFIXER_BROWSERS))
|
|
|
|
.pipe(gulp.dest('.tmp'))
|
|
|
|
// Concatenate Styles
|
|
|
|
.pipe($.concat('material-grid.css'))
|
|
|
|
.pipe($.header(banner, {pkg: pkg}))
|
|
|
|
.pipe(gulp.dest('./dist'))
|
|
|
|
// Minify Styles
|
|
|
|
.pipe($.if('*.css', $.csso()))
|
|
|
|
.pipe($.concat('material-grid.min.css'))
|
|
|
|
.pipe($.header(banner, {pkg: pkg}))
|
|
|
|
.pipe(gulp.dest('./dist'))
|
|
|
|
.pipe($.size({title: 'styles-grid'}));
|
|
|
|
});
|
|
|
|
|
2014-11-12 08:43:46 -08:00
|
|
|
// Concatenate And Minify JavaScript
|
2015-02-04 02:14:57 -08:00
|
|
|
gulp.task('scripts', function () {
|
2015-01-30 06:44:33 -08:00
|
|
|
var sources = [
|
|
|
|
// Component handler
|
2015-04-10 02:54:01 -07:00
|
|
|
'src/mdlComponentHandler.js',
|
2015-01-30 06:44:33 -08:00
|
|
|
// Polyfills/dependencies
|
2015-02-04 02:14:57 -08:00
|
|
|
'src/third_party/**/*.js',
|
2015-01-30 06:44:33 -08:00
|
|
|
// Base components
|
2015-02-04 02:14:57 -08:00
|
|
|
'src/button/button.js',
|
|
|
|
'src/checkbox/checkbox.js',
|
|
|
|
'src/icon-toggle/icon-toggle.js',
|
2015-02-16 09:14:45 -08:00
|
|
|
'src/menu/menu.js',
|
2015-04-01 05:35:08 -07:00
|
|
|
'src/progress/progress.js',
|
2015-02-04 02:14:57 -08:00
|
|
|
'src/radio/radio.js',
|
|
|
|
'src/slider/slider.js',
|
|
|
|
'src/spinner/spinner.js',
|
|
|
|
'src/switch/switch.js',
|
|
|
|
'src/tabs/tabs.js',
|
|
|
|
'src/textfield/textfield.js',
|
|
|
|
'src/tooltip/tooltip.js',
|
2015-01-30 06:44:33 -08:00
|
|
|
// Complex components (which reuse base components)
|
2015-02-04 02:14:57 -08:00
|
|
|
'src/layout/layout.js',
|
2015-05-27 09:27:24 -07:00
|
|
|
'src/data-table/data-table.js',
|
2015-01-30 06:44:33 -08:00
|
|
|
// And finally, the ripples
|
2015-02-04 02:14:57 -08:00
|
|
|
'src/ripple/ripple.js'
|
2015-01-30 06:44:33 -08:00
|
|
|
];
|
2015-01-20 09:54:59 -08:00
|
|
|
return gulp.src(sources)
|
2015-02-04 02:14:57 -08:00
|
|
|
.pipe($.sourcemaps.init())
|
|
|
|
// Concatenate Scripts
|
|
|
|
.pipe($.concat('material.js'))
|
2015-05-06 06:25:08 -07:00
|
|
|
.pipe(gulp.dest('./dist'))
|
2015-02-04 02:14:57 -08:00
|
|
|
// Minify Scripts
|
2015-06-30 09:44:52 -07:00
|
|
|
.pipe($.uglify({
|
|
|
|
sourceRoot: '.',
|
|
|
|
sourceMapIncludeSources: true
|
|
|
|
}))
|
|
|
|
.pipe($.header(banner, {pkg: pkg}))
|
2015-02-04 02:14:57 -08:00
|
|
|
.pipe($.concat('material.min.js'))
|
|
|
|
// Write Source Maps
|
|
|
|
.pipe($.sourcemaps.write('./'))
|
2015-05-06 06:25:08 -07:00
|
|
|
.pipe(gulp.dest('./dist'))
|
2014-11-12 08:43:46 -08:00
|
|
|
.pipe($.size({title: 'scripts'}));
|
|
|
|
});
|
|
|
|
|
2015-04-01 04:54:06 -07:00
|
|
|
// Clean Output Directory
|
2015-06-04 13:12:20 -07:00
|
|
|
gulp.task('clean', del.bind(null, ['dist', '.publish'], {dot: true}));
|
2015-04-01 04:54:06 -07:00
|
|
|
|
2015-07-05 04:04:15 -07:00
|
|
|
// Copy package manger and LICENSE files to dist
|
|
|
|
gulp.task('metadata', function () {
|
|
|
|
return gulp.src(['package.json', 'bower.json', 'LICENSE'])
|
|
|
|
.pipe(gulp.dest('./dist'));
|
|
|
|
});
|
|
|
|
|
2015-04-01 04:54:06 -07:00
|
|
|
// Build Production Files, the Default Task
|
2015-06-01 05:30:17 -07:00
|
|
|
gulp.task('default', ['clean', 'mocha'], function (cb) {
|
2015-04-01 04:54:06 -07:00
|
|
|
runSequence(
|
2015-07-05 08:37:22 -07:00
|
|
|
['styles', 'styles:gen'],
|
2015-06-23 06:29:34 -07:00
|
|
|
['jshint', 'jscs', 'scripts', 'styles', 'assets', 'demos', 'pages',
|
2015-07-05 04:04:15 -07:00
|
|
|
'templates', 'images', 'styles-grid', 'metadata'],
|
2015-04-01 04:54:06 -07:00
|
|
|
cb);
|
|
|
|
});
|
|
|
|
|
|
|
|
// ***** Testing tasks ***** //
|
|
|
|
|
2015-05-07 07:27:12 -07:00
|
|
|
gulp.task('mocha', ['styles'], function () {
|
2015-02-16 01:15:59 -08:00
|
|
|
return gulp.src('./test/index.html')
|
2015-06-24 03:30:48 -07:00
|
|
|
.pipe($.mochaPhantomjs({reporter: 'tap'}));
|
2015-02-10 05:19:18 -08:00
|
|
|
});
|
|
|
|
|
2015-06-15 02:26:18 -07:00
|
|
|
gulp.task('test', ['jshint', 'jscs', 'mocha']);
|
2014-04-17 05:02:38 -07:00
|
|
|
|
2015-04-01 04:54:06 -07:00
|
|
|
gulp.task('test:visual', function() {
|
2014-06-26 00:10:04 -07:00
|
|
|
browserSync({
|
2014-06-25 15:14:19 -07:00
|
|
|
notify: false,
|
2015-04-01 04:54:06 -07:00
|
|
|
server: './',
|
|
|
|
startPath: 'test/visual/index.html'
|
2014-06-20 08:20:44 -07:00
|
|
|
});
|
2014-04-17 05:02:38 -07:00
|
|
|
|
2015-04-01 04:54:06 -07:00
|
|
|
gulp.watch(['test/visual/**'], reload);
|
2014-04-17 05:02:38 -07:00
|
|
|
});
|
2014-06-07 10:38:49 -07:00
|
|
|
|
2015-04-01 04:54:06 -07:00
|
|
|
// ***** Landing page tasks ***** //
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Site metadata for use with templates.
|
|
|
|
* @type {Object}
|
|
|
|
*/
|
|
|
|
var site = {};
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Generates an HTML file based on a template and file metadata.
|
|
|
|
*/
|
|
|
|
function applyTemplate() {
|
|
|
|
return through.obj(function(file, enc, cb) {
|
|
|
|
var data = {
|
|
|
|
site: site,
|
|
|
|
page: file.page,
|
|
|
|
content: file.contents.toString()
|
|
|
|
};
|
2015-04-29 03:00:31 -07:00
|
|
|
|
|
|
|
var templateFile = path.join(
|
|
|
|
__dirname, 'docs', '_templates', file.page.layout + '.html');
|
|
|
|
var tpl = swig.compileFile(templateFile, {cache: false});
|
2015-04-01 04:54:06 -07:00
|
|
|
file.contents = new Buffer(tpl(data), 'utf8');
|
|
|
|
this.push(file);
|
|
|
|
cb();
|
2015-06-01 07:20:14 -07:00
|
|
|
});
|
2015-04-01 04:54:06 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Generates an index.html file for each README in MDL/src directory.
|
|
|
|
*/
|
2015-06-23 06:29:34 -07:00
|
|
|
gulp.task('components', ['demos'], function() {
|
2015-05-20 08:36:17 -07:00
|
|
|
return gulp.src(['./src/**/README.md'], {base: './src'})
|
2015-04-01 04:54:06 -07:00
|
|
|
// Add basic front matter.
|
2015-06-02 06:59:21 -07:00
|
|
|
.pipe($.header('---\nlayout: component\nbodyclass: component\ninclude_prefix: ../../\n---\n\n'))
|
2015-04-01 04:54:06 -07:00
|
|
|
.pipe($.frontMatter({property: 'page', remove: true}))
|
|
|
|
.pipe($.marked())
|
|
|
|
.pipe((function () {
|
|
|
|
var componentPages = [];
|
|
|
|
return through.obj(function(file, enc, cb) {
|
|
|
|
file.page.component = file.relative.split('/')[0];
|
|
|
|
componentPages.push(file.page);
|
|
|
|
this.push(file);
|
|
|
|
cb();
|
|
|
|
},
|
|
|
|
function(cb) {
|
|
|
|
site.components = componentPages;
|
|
|
|
cb();
|
2015-06-01 07:20:14 -07:00
|
|
|
});
|
2015-04-01 04:54:06 -07:00
|
|
|
})())
|
|
|
|
.pipe(applyTemplate())
|
|
|
|
.pipe($.rename(function (path) {
|
2015-06-01 07:20:14 -07:00
|
|
|
path.basename = 'index';
|
2015-04-01 04:54:06 -07:00
|
|
|
}))
|
2015-05-06 06:25:08 -07:00
|
|
|
.pipe(gulp.dest('dist/components'));
|
2014-06-30 13:18:52 -07:00
|
|
|
});
|
|
|
|
|
2015-04-01 04:54:06 -07:00
|
|
|
/**
|
|
|
|
* Copies demo files from MDL/src directory.
|
|
|
|
*/
|
2015-06-23 06:29:34 -07:00
|
|
|
gulp.task('demoresources', function () {
|
2015-06-01 05:30:17 -07:00
|
|
|
return gulp.src([
|
2015-06-23 06:29:34 -07:00
|
|
|
'./src/**/demos.css',
|
|
|
|
'./src/**/demo.css',
|
|
|
|
'./src/**/demo.js'
|
2015-06-01 05:30:17 -07:00
|
|
|
], {base: './src'})
|
2015-04-01 04:54:06 -07:00
|
|
|
.pipe($.if('*.scss', $.sass({
|
|
|
|
precision: 10,
|
|
|
|
onError: console.error.bind(console, 'Sass error:')
|
|
|
|
})))
|
2015-05-07 19:01:05 -07:00
|
|
|
.pipe($.cssInlineImages({
|
|
|
|
webRoot: 'src'
|
2015-04-16 04:55:04 -07:00
|
|
|
}))
|
2015-04-01 04:54:06 -07:00
|
|
|
.pipe($.if('*.css', $.autoprefixer(AUTOPREFIXER_BROWSERS)))
|
2015-05-06 06:25:08 -07:00
|
|
|
.pipe(gulp.dest('dist/components'));
|
2014-06-07 10:38:49 -07:00
|
|
|
});
|
2015-02-16 01:15:59 -08:00
|
|
|
|
2015-06-11 08:02:19 -07:00
|
|
|
/**
|
2015-06-23 09:22:22 -07:00
|
|
|
* Generates demo files for testing made of all the snippets and the demo file
|
|
|
|
* put together.
|
2015-06-11 08:02:19 -07:00
|
|
|
*/
|
2015-06-23 06:29:34 -07:00
|
|
|
gulp.task('demos', ['demoresources'], function() {
|
2015-06-23 09:22:22 -07:00
|
|
|
|
|
|
|
function getComponentFolders() {
|
|
|
|
return fs.readdirSync('./src/')
|
|
|
|
.filter(function(file) {
|
|
|
|
return fs.statSync(path.join('./src/', file)).isDirectory();
|
2015-06-11 08:02:19 -07:00
|
|
|
});
|
2015-06-23 09:22:22 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
var tasks = getComponentFolders().map(function(component) {
|
|
|
|
return gulp.src([
|
|
|
|
'./src/' + component + '/snippets/*.html',
|
|
|
|
'./src/' + component + '/demo.html'
|
|
|
|
])
|
|
|
|
.pipe($.concat('/demo.html'))
|
|
|
|
// Add basic front matter.
|
|
|
|
.pipe($.header('---\nlayout: demo\nbodyclass: demo\ninclude_prefix: ../../\n---\n\n'))
|
|
|
|
.pipe($.frontMatter({property: 'page', remove: true}))
|
|
|
|
.pipe($.marked())
|
|
|
|
.pipe((function () {
|
|
|
|
var componentPages = [];
|
|
|
|
return through.obj(function(file, enc, cb) {
|
|
|
|
file.page.component = component;
|
|
|
|
componentPages.push(file.page);
|
|
|
|
this.push(file);
|
|
|
|
cb();
|
|
|
|
},
|
|
|
|
function(cb) {
|
|
|
|
site.components = componentPages;
|
|
|
|
cb();
|
|
|
|
});
|
|
|
|
})())
|
|
|
|
.pipe(applyTemplate())
|
|
|
|
.pipe(gulp.dest('dist/components/' + component));
|
|
|
|
});
|
|
|
|
|
|
|
|
return merge(tasks);
|
2015-06-11 08:02:19 -07:00
|
|
|
});
|
|
|
|
|
2015-04-01 04:54:06 -07:00
|
|
|
/**
|
|
|
|
* Generates an HTML file for each md file in _pages directory.
|
|
|
|
*/
|
|
|
|
gulp.task('pages', ['components'], function() {
|
|
|
|
return gulp.src(['docs/_pages/*.md'])
|
|
|
|
.pipe($.frontMatter({property: 'page', remove: true}))
|
|
|
|
.pipe($.marked())
|
|
|
|
.pipe(applyTemplate())
|
2015-06-16 06:33:52 -07:00
|
|
|
.pipe($.replace('$$version$$', pkg.version))
|
2015-06-24 07:57:57 -07:00
|
|
|
.pipe($.replace('$$hosted_libs_prefix$$', hostedLibsUrlPrefix))
|
2015-06-11 06:43:36 -07:00
|
|
|
/* Replacing code blocks class name to match Prism's. */
|
2015-06-15 09:36:58 -07:00
|
|
|
.pipe($.replace('class="lang-', 'class="language-'))
|
2015-06-11 06:43:36 -07:00
|
|
|
/* Translate html code blocks to "markup" because that's what Prism uses. */
|
2015-06-15 09:36:58 -07:00
|
|
|
.pipe($.replace('class="language-html', 'class="language-markup'))
|
2015-04-01 04:54:06 -07:00
|
|
|
.pipe($.rename(function(path) {
|
|
|
|
if (path.basename !== 'index') {
|
|
|
|
path.dirname = path.basename;
|
|
|
|
path.basename = 'index';
|
|
|
|
}
|
|
|
|
}))
|
2015-05-06 06:25:08 -07:00
|
|
|
.pipe(gulp.dest('dist'));
|
2015-04-01 04:54:06 -07:00
|
|
|
});
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Copies assets from MDL and _assets directory.
|
|
|
|
*/
|
|
|
|
gulp.task('assets', function () {
|
2015-06-23 09:22:22 -07:00
|
|
|
return gulp.src([
|
|
|
|
'docs/_assets/**/*',
|
|
|
|
'node_modules/clippy/build/clippy.swf',
|
2015-07-02 08:28:27 -07:00
|
|
|
'node_modules/swfobject-npm/swfobject/src/swfobject.js',
|
|
|
|
'node_modules/prismjs/prism.js',
|
|
|
|
'node_modules/prismjs/components/prism-markup.min.js',
|
2015-07-03 05:09:44 -07:00
|
|
|
'node_modules/prismjs/components/prism-javascript.min.js',
|
|
|
|
'node_modules/prismjs/components/prism-css.min.js',
|
2015-07-02 08:28:27 -07:00
|
|
|
'node_modules/prismjs/dist/prism-default/prism-default.css'
|
2015-06-23 09:22:22 -07:00
|
|
|
])
|
2015-06-24 16:11:14 -07:00
|
|
|
.pipe($.if(/\.js/i, $.replace('$$version$$', pkg.version)))
|
|
|
|
.pipe($.if(/\.js/i, $.replace('$$hosted_libs_prefix$$', hostedLibsUrlPrefix)))
|
2015-04-29 03:00:31 -07:00
|
|
|
.pipe($.if(/\.(svg|jpg|png)$/i, $.imagemin({
|
|
|
|
progressive: true,
|
|
|
|
interlaced: true
|
|
|
|
})))
|
2015-06-02 16:01:04 -07:00
|
|
|
.pipe($.if(/\.css/i, $.autoprefixer(AUTOPREFIXER_BROWSERS)))
|
2015-07-02 12:31:50 -07:00
|
|
|
.pipe($.if(/\.css/i, $.csso()))
|
2015-06-17 09:49:23 -07:00
|
|
|
.pipe($.if(/\.js/i, $.uglify({preserveComments: 'some', sourceRoot: '.',
|
|
|
|
sourceMapIncludeSources: true})))
|
2015-05-06 06:25:08 -07:00
|
|
|
.pipe(gulp.dest('dist/assets'));
|
2015-04-01 04:54:06 -07:00
|
|
|
});
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Serves the landing page from "out" directory.
|
|
|
|
*/
|
2015-06-04 13:59:06 -07:00
|
|
|
gulp.task('serve:browsersync', ['default'], function () {
|
2015-03-23 08:56:23 -07:00
|
|
|
browserSync({
|
|
|
|
notify: false,
|
2015-04-01 04:54:06 -07:00
|
|
|
server: {
|
2015-06-01 07:15:55 -07:00
|
|
|
baseDir: ['dist']
|
2015-04-01 04:54:06 -07:00
|
|
|
}
|
2015-03-23 08:56:23 -07:00
|
|
|
});
|
|
|
|
|
2015-06-01 07:20:14 -07:00
|
|
|
gulp.watch(['src/**/*.js', '!src/**/README.md'],
|
|
|
|
['scripts', 'demos', 'components', reload]);
|
2015-04-17 04:28:57 -07:00
|
|
|
gulp.watch(['src/**/*.{scss,css}'], ['styles', 'demos', reload]);
|
|
|
|
gulp.watch(['src/**/*.html'], ['demos', reload]);
|
2015-04-01 04:54:06 -07:00
|
|
|
gulp.watch(['src/**/README.md'], ['components', reload]);
|
2015-04-16 03:37:38 -07:00
|
|
|
gulp.watch(['templates/**/*'], ['templates', reload]);
|
2015-05-06 07:12:33 -07:00
|
|
|
gulp.watch(['docs/**/*'], ['pages', 'assets', reload]);
|
2015-03-23 08:56:23 -07:00
|
|
|
});
|
2015-04-15 07:13:10 -07:00
|
|
|
|
2015-06-04 13:59:06 -07:00
|
|
|
gulp.task('serve', ['default'], function() {
|
|
|
|
$.connect.server({
|
|
|
|
root: 'dist',
|
2015-06-05 10:07:09 -07:00
|
|
|
port: 5000,
|
2015-06-04 13:59:06 -07:00
|
|
|
livereload: true
|
|
|
|
});
|
|
|
|
|
|
|
|
gulp.watch(['src/**/*.js', '!src/**/README.md'],
|
|
|
|
['scripts', 'demos', 'components']);
|
|
|
|
gulp.watch(['src/**/*.{scss,css}'], ['styles', 'demos']);
|
|
|
|
gulp.watch(['src/**/*.html'], ['demos']);
|
|
|
|
gulp.watch(['src/**/README.md'], ['components']);
|
|
|
|
gulp.watch(['templates/**/*'], ['templates']);
|
|
|
|
gulp.watch(['docs/**/*'], ['pages', 'assets']);
|
2015-06-05 10:07:09 -07:00
|
|
|
|
|
|
|
gulp.src('./dist/index.html')
|
|
|
|
.pipe($.open('', {url: 'http://localhost:5000'}));
|
2015-06-04 13:59:06 -07:00
|
|
|
});
|
|
|
|
|
2015-06-29 10:54:20 -07:00
|
|
|
// Generate release archive containing just JS, CSS, Source Map deps
|
|
|
|
gulp.task('zip:mdl', function() {
|
2015-07-06 04:03:35 -07:00
|
|
|
return gulp.src(['dist/material?(.min)@(.js|.css)?(.map)', 'LICENSE', 'bower.json', 'package.json'])
|
2015-06-29 10:54:20 -07:00
|
|
|
.pipe($.zip('mdl.zip'))
|
|
|
|
.pipe(gulp.dest('dist'));
|
|
|
|
});
|
|
|
|
|
2015-06-30 06:02:35 -07:00
|
|
|
// Generate release archive containing the library, templates and assets
|
|
|
|
// for templates. Note that it is intentional for some templates to include
|
|
|
|
// a customised version of the material.min.css file for their own needs.
|
|
|
|
// Others (e.g the Android template) simply use the default built version of
|
|
|
|
// the library.
|
|
|
|
|
|
|
|
// Define a filter containing only the build assets we want to pluck from the
|
|
|
|
// `dist` stream. This enables us to preserve the correct final dir structure,
|
|
|
|
// which was not occurring when simply using `gulp.src` in `zip:templates`
|
|
|
|
|
|
|
|
var fileFilter = $.filter([
|
|
|
|
'material.*@(js|css)?(.map)',
|
|
|
|
'templates/**/*.*',
|
|
|
|
'assets/**/*.*',
|
|
|
|
'LICENSE',
|
|
|
|
'bower.json',
|
|
|
|
'package.json']);
|
|
|
|
|
2015-06-30 03:43:39 -07:00
|
|
|
gulp.task('zip:templates', function() {
|
2015-06-30 06:02:35 -07:00
|
|
|
// Stream of all `dist` files and other package manager files from root
|
2015-07-06 04:03:35 -07:00
|
|
|
return gulp.src(['dist/**/*.*', 'LICENSE', 'bower.json', 'package.json'])
|
2015-06-30 06:02:35 -07:00
|
|
|
.pipe(fileFilter)
|
|
|
|
.pipe($.zip('mdl-templates.zip'))
|
|
|
|
.pipe(fileFilter.restore())
|
|
|
|
.pipe(gulp.dest('dist'));
|
2015-06-29 10:54:20 -07:00
|
|
|
});
|
|
|
|
|
2015-07-05 11:17:45 -07:00
|
|
|
gulp.task('genCodeFiles', function() {
|
|
|
|
return gulp.src(['dist/material.*@(js|css)?(.map)', 'dist/mdl.zip', 'dist/mdl-templates.zip'],
|
|
|
|
{read: false})
|
|
|
|
.pipe($.tap(function(file, t) {
|
|
|
|
codeFiles += ' dist/' + path.basename(file.path);
|
|
|
|
}));
|
|
|
|
});
|
|
|
|
|
2015-06-24 10:07:33 -07:00
|
|
|
// Push the latest version of code resources (CSS+JS) to Google Cloud Storage.
|
2015-06-19 06:28:48 -07:00
|
|
|
// Public-read objects in GCS are served by a Google provided and supported
|
|
|
|
// global, high performance caching/content delivery network (CDN) service.
|
2015-06-12 08:50:10 -07:00
|
|
|
// This task requires gsutil to be installed and configured.
|
2015-06-19 06:28:48 -07:00
|
|
|
// For info on gsutil: https://cloud.google.com/storage/docs/gsutil.
|
2015-07-06 03:38:31 -07:00
|
|
|
gulp.task('pushCodeFiles', function() {
|
2015-06-22 11:46:15 -07:00
|
|
|
// Build dest path, info message, cache control and gsutil cmd to copy
|
2015-06-19 06:28:48 -07:00
|
|
|
// each object into a GCS bucket. The dest is a version specific path.
|
|
|
|
// The gsutil -m option requests parallel copies.
|
2015-06-24 10:07:33 -07:00
|
|
|
// The gsutil -h option is used to set metadata headers
|
|
|
|
// (cache control, in this case).
|
2015-06-19 06:28:48 -07:00
|
|
|
// For cache control, start with 0s (disable caching during dev),
|
|
|
|
// but consider more helpful interval (e.g. 3600s) after launch.
|
2015-06-25 03:34:00 -07:00
|
|
|
var dest = bucketCode;
|
|
|
|
var infoMsg = 'Publishing ' + pkg.version + ' to CDN (' + dest + ')';
|
2015-07-05 12:43:13 -07:00
|
|
|
var cacheControl = '-h "Cache-Control:public,max-age=60"';
|
2015-07-05 11:17:45 -07:00
|
|
|
var gsutilCpCmd = 'gsutil -m cp ';
|
|
|
|
var gsutilCacheCmd = 'gsutil -m setmeta -R ' + cacheControl;
|
2015-06-19 06:28:48 -07:00
|
|
|
|
2015-06-25 03:34:00 -07:00
|
|
|
process.stdout.write(infoMsg + '\n');
|
2015-06-24 10:07:33 -07:00
|
|
|
// Upload the goodies to a separate GCS bucket with versioning.
|
|
|
|
// Using a sep bucket avoids the risk of accidentally blowing away
|
|
|
|
// old versions in the microsite bucket.
|
2015-07-06 04:03:35 -07:00
|
|
|
return gulp.src('')
|
2015-06-19 06:28:48 -07:00
|
|
|
.pipe($.shell([
|
2015-07-05 11:17:45 -07:00
|
|
|
gsutilCpCmd + codeFiles + ' ' + dest + '/' + pkg.version,
|
|
|
|
gsutilCacheCmd + ' ' + dest + '/' + pkg.version
|
2015-06-19 06:28:48 -07:00
|
|
|
]));
|
2015-06-12 08:50:10 -07:00
|
|
|
});
|
|
|
|
|
2015-07-05 11:17:45 -07:00
|
|
|
gulp.task('publish:code', function (cb) {
|
|
|
|
runSequence(
|
2015-07-06 03:55:11 -07:00
|
|
|
['zip:mdl', 'zip:templates'],
|
2015-07-05 11:17:45 -07:00
|
|
|
'genCodeFiles',
|
|
|
|
'pushCodeFiles',
|
|
|
|
cb);
|
|
|
|
});
|
|
|
|
|
2015-06-25 06:16:41 -07:00
|
|
|
// Function to publish staging or prod version from local tree,
|
2015-06-24 05:40:47 -07:00
|
|
|
// or to promote staging to prod, per passed arg.
|
2015-06-25 03:34:00 -07:00
|
|
|
function mdlPublish(pubScope) {
|
|
|
|
var cacheTtl = null;
|
2015-06-24 05:40:47 -07:00
|
|
|
var src = null;
|
|
|
|
var dest = null;
|
2015-06-25 03:34:00 -07:00
|
|
|
if (pubScope === 'staging') {
|
2015-06-24 05:40:47 -07:00
|
|
|
// Set staging specific vars here.
|
2015-06-25 03:34:00 -07:00
|
|
|
cacheTtl = 0;
|
|
|
|
dest = bucketStaging;
|
|
|
|
} else if (pubScope === 'prod') {
|
2015-06-24 05:40:47 -07:00
|
|
|
// Set prod specific vars here.
|
2015-07-05 12:25:22 -07:00
|
|
|
cacheTtl = 60;
|
2015-06-25 03:34:00 -07:00
|
|
|
dest = bucketProd;
|
|
|
|
} else if (pubScope === 'promote') {
|
2015-06-24 05:40:47 -07:00
|
|
|
// Set promote (essentially prod) specific vars here.
|
2015-07-05 12:25:22 -07:00
|
|
|
cacheTtl = 60;
|
2015-06-25 03:34:00 -07:00
|
|
|
src = bucketStaging + '/*';
|
|
|
|
dest = bucketProd;
|
2015-04-15 07:13:10 -07:00
|
|
|
}
|
|
|
|
|
2015-06-24 05:40:47 -07:00
|
|
|
// Build cache control and info message.
|
2015-06-25 03:34:00 -07:00
|
|
|
var cacheControl = '-h "Cache-Control:public,max-age=' + cacheTtl + '"';
|
|
|
|
var infoMsg = 'Publishing ' + pubScope + '/' + pkg.version + ' to GCS (' + dest + ')';
|
2015-06-24 05:40:47 -07:00
|
|
|
if (src) {
|
2015-06-25 03:34:00 -07:00
|
|
|
infoMsg += ' from ' + src;
|
2015-06-24 05:40:47 -07:00
|
|
|
}
|
2015-06-19 06:28:48 -07:00
|
|
|
|
|
|
|
// Build gsutil commands to recursively sync local distribution tree
|
|
|
|
// to the dest bucket and to recursively set permissions to public-read.
|
|
|
|
// The gsutil -m option requests parallel copies.
|
2015-07-01 05:55:47 -07:00
|
|
|
// The gsutil -R option is used for recursive file copy.
|
2015-06-19 06:28:48 -07:00
|
|
|
// The gsutil -h option is used to set metadata headers (cache control, in this case).
|
2015-06-25 03:34:00 -07:00
|
|
|
var gsutilSyncCmd = 'gsutil -m rsync -d -R dist ' + dest;
|
|
|
|
var gsutilCacheCmd = 'gsutil -m setmeta ' + cacheControl + ' ' + dest + '/**';
|
|
|
|
var gsutilCpCmd = 'gsutil -m cp -R ' + src + ' ' + dest;
|
2015-06-19 06:28:48 -07:00
|
|
|
|
2015-06-25 03:34:00 -07:00
|
|
|
process.stdout.write(infoMsg + '\n');
|
|
|
|
if (pubScope === 'promote') {
|
2015-06-24 05:40:47 -07:00
|
|
|
// If promoting, copy staging bucket contents to prod bucket,
|
|
|
|
// and set ACLs and cache control on dest contents.
|
2015-07-01 05:29:51 -07:00
|
|
|
gulp.src('').pipe($.shell([gsutilCpCmd, gsutilCacheCmd]));
|
2015-06-24 05:40:47 -07:00
|
|
|
} else {
|
|
|
|
// If publishing to prod directly, rsync local contents to prod bucket,
|
|
|
|
// and set ACLs and cache control on dest contents.
|
2015-07-01 05:29:51 -07:00
|
|
|
gulp.src('').pipe($.shell([gsutilSyncCmd, gsutilCacheCmd]));
|
2015-06-24 05:40:47 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// Push the local build of the MDL microsite and release artifacts to the
|
|
|
|
// production Google Cloud Storage bucket for general serving to the web.
|
|
|
|
// Public-read objects in GCS are served by a Google provided and supported
|
|
|
|
// global, high performance caching/content delivery network (CDN) service.
|
|
|
|
// This task requires gsutil to be installed and configured.
|
|
|
|
// For info on gsutil: https://cloud.google.com/storage/docs/gsutil.
|
|
|
|
//
|
|
|
|
gulp.task('publish:prod', function() {
|
2015-06-25 03:34:00 -07:00
|
|
|
mdlPublish('prod');
|
2015-06-24 05:40:47 -07:00
|
|
|
});
|
|
|
|
|
|
|
|
// Promote the staging version of the MDL microsite and release artifacts
|
|
|
|
// to the production Google Cloud Storage bucket for general serving.
|
|
|
|
// Public-read objects in GCS are served by a Google provided and supported
|
|
|
|
// global, high performance caching/content delivery network (CDN) service.
|
|
|
|
// This task requires gsutil to be installed and configured.
|
|
|
|
// For info on gsutil: https://cloud.google.com/storage/docs/gsutil.
|
|
|
|
//
|
|
|
|
gulp.task('publish:promote', function() {
|
2015-06-25 03:34:00 -07:00
|
|
|
mdlPublish('promote');
|
2015-06-24 05:40:47 -07:00
|
|
|
});
|
|
|
|
|
|
|
|
// Push the staged version of the MDL microsite and release artifacts
|
|
|
|
// to a production Google Cloud Storage bucket for staging and pre-production testing.
|
|
|
|
//
|
|
|
|
// This task requires gsutil to be installed and configured.
|
|
|
|
// For info on gsutil: https://cloud.google.com/storage/docs/gsutil.
|
|
|
|
//
|
|
|
|
gulp.task('publish:staging', function() {
|
2015-06-25 03:34:00 -07:00
|
|
|
mdlPublish('staging');
|
2015-06-19 06:28:48 -07:00
|
|
|
});
|
|
|
|
|
2015-05-13 07:59:31 -07:00
|
|
|
gulp.task('templates:mdl', function() {
|
2015-04-16 03:37:38 -07:00
|
|
|
return gulp.src([
|
|
|
|
'templates/**/*.scss'
|
|
|
|
])
|
|
|
|
.pipe($.sass({
|
|
|
|
precision: 10,
|
|
|
|
onError: console.error.bind(console, 'Sass error:')
|
|
|
|
}))
|
2015-05-07 19:01:05 -07:00
|
|
|
.pipe($.cssInlineImages({
|
|
|
|
webRoot: 'src'
|
2015-04-16 06:43:19 -07:00
|
|
|
}))
|
2015-04-16 03:37:38 -07:00
|
|
|
.pipe($.autoprefixer(AUTOPREFIXER_BROWSERS))
|
2015-05-13 07:59:31 -07:00
|
|
|
.pipe($.csso())
|
2015-04-16 03:37:38 -07:00
|
|
|
.pipe($.rename({suffix: '.min'}))
|
2015-05-13 07:59:31 -07:00
|
|
|
.pipe(gulp.dest('dist/templates'));
|
|
|
|
});
|
|
|
|
|
|
|
|
gulp.task('templates:styles', function() {
|
|
|
|
return gulp.src([
|
|
|
|
'templates/**/*.css'
|
|
|
|
])
|
|
|
|
.pipe($.autoprefixer(AUTOPREFIXER_BROWSERS))
|
|
|
|
// FIXME: This crashes. It's a bug in gulp-csso,
|
|
|
|
// not csso itself.
|
|
|
|
//.pipe($.csso())
|
|
|
|
.pipe(gulp.dest('dist/templates'));
|
2015-04-16 03:37:38 -07:00
|
|
|
});
|
2015-04-15 09:09:28 -07:00
|
|
|
|
2015-04-16 03:37:38 -07:00
|
|
|
gulp.task('templates:static', function() {
|
|
|
|
return gulp.src([
|
|
|
|
'templates/**/*.html',
|
|
|
|
])
|
2015-05-06 06:25:08 -07:00
|
|
|
.pipe(gulp.dest('dist/templates'));
|
2015-04-16 03:37:38 -07:00
|
|
|
});
|
|
|
|
|
|
|
|
gulp.task('templates:images', function() {
|
|
|
|
return gulp.src([
|
|
|
|
'templates/*/images/**/*'
|
|
|
|
])
|
|
|
|
.pipe($.imagemin({
|
|
|
|
progressive: true,
|
|
|
|
interlaced: true
|
|
|
|
}))
|
2015-05-06 06:25:08 -07:00
|
|
|
.pipe(gulp.dest('dist/templates'));
|
2015-04-16 03:37:38 -07:00
|
|
|
});
|
|
|
|
|
2015-04-16 04:20:01 -07:00
|
|
|
gulp.task('templates:fonts', function() {
|
|
|
|
return gulp.src([
|
2015-06-16 07:41:51 -07:00
|
|
|
'templates/*/fonts/**/*'
|
|
|
|
])
|
2015-05-06 06:25:08 -07:00
|
|
|
.pipe(gulp.dest('dist/templates/'));
|
2015-06-01 07:20:14 -07:00
|
|
|
});
|
2015-04-16 04:20:01 -07:00
|
|
|
|
2015-06-01 07:20:14 -07:00
|
|
|
gulp.task('templates', ['templates:static', 'templates:images', 'templates:mdl',
|
2015-06-16 07:41:51 -07:00
|
|
|
'templates:fonts', 'templates:styles']);
|
2015-07-01 06:40:42 -07:00
|
|
|
|
|
|
|
gulp.task('styles:gen', ['styles'], function() {
|
|
|
|
// TODO: This task needs refactoring once we turn MaterialCustomizer
|
|
|
|
// into a proper Node module.
|
|
|
|
var mc = new MaterialCustomizer();
|
|
|
|
mc.template = fs.readFileSync('./dist/material.min.css.template').toString();
|
|
|
|
|
|
|
|
var stream = gulp.src('');
|
|
|
|
mc.paletteIndices.forEach(function(primary) {
|
|
|
|
mc.paletteIndices.forEach(function(accent) {
|
|
|
|
if (mc.forbiddenAccents.indexOf(accent) !== -1) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
var primaryName = primary.toLowerCase().replace(' ', '_');
|
|
|
|
var accentName = accent.toLowerCase().replace(' ', '_');
|
|
|
|
stream = stream.pipe($.file(
|
|
|
|
'material.' + primaryName + '-' + accentName + '.min.css',
|
|
|
|
mc.processTemplate(primary, accent)
|
|
|
|
));
|
|
|
|
});
|
|
|
|
});
|
|
|
|
stream.pipe(gulp.dest('dist'));
|
|
|
|
});
|