Adjust gulpfile to styleguide

This commit is contained in:
Surma 2015-08-06 12:39:04 +01:00
parent ee8c302c10
commit f2ef6663ce

View File

@ -62,7 +62,7 @@ var AUTOPREFIXER_BROWSERS = [
// ***** Development tasks ****** // // ***** Development tasks ****** //
// Lint JavaScript // Lint JavaScript
gulp.task('jshint', function () { gulp.task('jshint', function() {
return gulp.src(['src/**/*.js' , 'gulpfile.js']) return gulp.src(['src/**/*.js' , 'gulpfile.js'])
.pipe(reload({stream: true, once: true})) .pipe(reload({stream: true, once: true}))
.pipe($.jshint()) .pipe($.jshint())
@ -71,7 +71,7 @@ gulp.task('jshint', function () {
}); });
// Lint JavaScript code style // Lint JavaScript code style
gulp.task('jscs', function () { gulp.task('jscs', function() {
return gulp.src(['src/**/*.js' , 'gulpfile.js']) return gulp.src(['src/**/*.js' , 'gulpfile.js'])
.pipe(reload({stream: true, once: true})) .pipe(reload({stream: true, once: true}))
.pipe($.jscs()) .pipe($.jscs())
@ -82,7 +82,7 @@ gulp.task('jscs', function () {
// Optimize Images // Optimize Images
// TODO: Update image paths in final CSS to match root/images // TODO: Update image paths in final CSS to match root/images
gulp.task('images', function () { gulp.task('images', function() {
return gulp.src('src/**/*.{svg,png,jpg}') return gulp.src('src/**/*.{svg,png,jpg}')
.pipe($.flatten()) .pipe($.flatten())
.pipe($.cache($.imagemin({ .pipe($.cache($.imagemin({
@ -94,7 +94,7 @@ gulp.task('images', function () {
}); });
// Compile and Automatically Prefix Stylesheets (dev) // Compile and Automatically Prefix Stylesheets (dev)
gulp.task('styles:dev', function () { gulp.task('styles:dev', function() {
return gulp.src([ return gulp.src([
'src/**/*.scss' 'src/**/*.scss'
]) ])
@ -111,13 +111,13 @@ gulp.task('styles:dev', function () {
}); });
// Compile and Automatically Prefix Stylesheet Templates (production) // Compile and Automatically Prefix Stylesheet Templates (production)
gulp.task('styletemplates', function () { gulp.task('styletemplates', function() {
// For best performance, don't add Sass partials to `gulp.src` // For best performance, don't add Sass partials to `gulp.src`
return gulp.src([ return gulp.src([
'src/template.scss' 'src/template.scss'
]) ])
// Generate Source Maps // Generate Source Maps
.pipe ($.sourcemaps.init()) .pipe($.sourcemaps.init())
.pipe($.sass({ .pipe($.sass({
precision: 10, precision: 10,
onError: console.error.bind(console, 'Sass error:') onError: console.error.bind(console, 'Sass error:')
@ -140,13 +140,13 @@ gulp.task('styletemplates', function () {
}); });
// Compile and Automatically Prefix Stylesheets (production) // Compile and Automatically Prefix Stylesheets (production)
gulp.task('styles', function () { gulp.task('styles', function() {
// For best performance, don't add Sass partials to `gulp.src` // For best performance, don't add Sass partials to `gulp.src`
return gulp.src([ return gulp.src([
'src/styleguide.scss' 'src/styleguide.scss'
]) ])
// Generate Source Maps // Generate Source Maps
.pipe ($.sourcemaps.init()) .pipe($.sourcemaps.init())
.pipe($.sass({ .pipe($.sass({
precision: 10, precision: 10,
onError: console.error.bind(console, 'Sass error:') onError: console.error.bind(console, 'Sass error:')
@ -170,7 +170,7 @@ gulp.task('styles', function () {
}); });
// Only generate CSS styles for the MDL grid // Only generate CSS styles for the MDL grid
gulp.task('styles-grid', function () { gulp.task('styles-grid', function() {
return gulp.src(['src/material-design-lite-grid.scss']) return gulp.src(['src/material-design-lite-grid.scss'])
.pipe($.sass({ .pipe($.sass({
precision: 10, precision: 10,
@ -191,7 +191,7 @@ gulp.task('styles-grid', function () {
}); });
// Concatenate And Minify JavaScript // Concatenate And Minify JavaScript
gulp.task('scripts', ['jscs', 'jshint'], function () { gulp.task('scripts', ['jscs', 'jshint'], function() {
var sources = [ var sources = [
// Component handler // Component handler
'src/mdlComponentHandler.js', 'src/mdlComponentHandler.js',
@ -238,13 +238,13 @@ gulp.task('scripts', ['jscs', 'jshint'], function () {
gulp.task('clean', del.bind(null, ['dist', '.publish'], {dot: true})); gulp.task('clean', del.bind(null, ['dist', '.publish'], {dot: true}));
// Copy package manger and LICENSE files to dist // Copy package manger and LICENSE files to dist
gulp.task('metadata', function () { gulp.task('metadata', function() {
return gulp.src(['package.json', 'bower.json', 'LICENSE']) return gulp.src(['package.json', 'bower.json', 'LICENSE'])
.pipe(gulp.dest('./dist')); .pipe(gulp.dest('./dist'));
}); });
// Build Production Files, the Default Task // Build Production Files, the Default Task
gulp.task('default', ['clean', 'mocha'], function (cb) { gulp.task('default', ['clean', 'mocha'], function(cb) {
runSequence( runSequence(
['styles', 'styles-grid'], ['styles', 'styles-grid'],
['scripts'], ['scripts'],
@ -252,7 +252,7 @@ gulp.task('default', ['clean', 'mocha'], function (cb) {
}); });
// Build production files and microsite // Build production files and microsite
gulp.task('all', ['clean', 'mocha'], function (cb) { gulp.task('all', ['clean', 'mocha'], function(cb) {
runSequence( runSequence(
['default', 'styletemplates'], ['default', 'styletemplates'],
['styles:gen'], ['styles:gen'],
@ -264,7 +264,7 @@ gulp.task('all', ['clean', 'mocha'], function (cb) {
// ***** Testing tasks ***** // // ***** Testing tasks ***** //
gulp.task('mocha', ['styles'], function () { gulp.task('mocha', ['styles'], function() {
return gulp.src('./test/index.html') return gulp.src('./test/index.html')
.pipe($.mochaPhantomjs({reporter: 'tap'})); .pipe($.mochaPhantomjs({reporter: 'tap'}));
}); });
@ -318,7 +318,7 @@ gulp.task('components', ['demos'], function() {
.pipe($.header('---\nlayout: component\nbodyclass: component\ninclude_prefix: ../../\n---\n\n')) .pipe($.header('---\nlayout: component\nbodyclass: component\ninclude_prefix: ../../\n---\n\n'))
.pipe($.frontMatter({property: 'page', remove: true})) .pipe($.frontMatter({property: 'page', remove: true}))
.pipe($.marked()) .pipe($.marked())
.pipe((function () { .pipe((function() {
return through.obj(function(file, enc, cb) { return through.obj(function(file, enc, cb) {
file.page.component = file.relative.split('/')[0]; file.page.component = file.relative.split('/')[0];
this.push(file); this.push(file);
@ -326,7 +326,7 @@ gulp.task('components', ['demos'], function() {
}); });
})()) })())
.pipe(applyTemplate()) .pipe(applyTemplate())
.pipe($.rename(function (path) { .pipe($.rename(function(path) {
path.basename = 'index'; path.basename = 'index';
})) }))
.pipe(gulp.dest('dist/components')); .pipe(gulp.dest('dist/components'));
@ -335,7 +335,7 @@ gulp.task('components', ['demos'], function() {
/** /**
* Copies demo files from MDL/src directory. * Copies demo files from MDL/src directory.
*/ */
gulp.task('demoresources', function () { gulp.task('demoresources', function() {
return gulp.src([ return gulp.src([
'./src/**/demos.css', './src/**/demos.css',
'./src/**/demo.css', './src/**/demo.css',
@ -357,7 +357,6 @@ gulp.task('demoresources', function () {
* put together. * put together.
*/ */
gulp.task('demos', ['demoresources'], function() { gulp.task('demos', ['demoresources'], function() {
function getComponentFolders() { function getComponentFolders() {
return fs.readdirSync('./src/') return fs.readdirSync('./src/')
.filter(function(file) { .filter(function(file) {
@ -375,7 +374,7 @@ gulp.task('demos', ['demoresources'], function() {
.pipe($.header('---\nlayout: demo\nbodyclass: demo\ninclude_prefix: ../../\n---\n\n')) .pipe($.header('---\nlayout: demo\nbodyclass: demo\ninclude_prefix: ../../\n---\n\n'))
.pipe($.frontMatter({property: 'page', remove: true})) .pipe($.frontMatter({property: 'page', remove: true}))
.pipe($.marked()) .pipe($.marked())
.pipe((function () { .pipe((function() {
return through.obj(function(file, enc, cb) { return through.obj(function(file, enc, cb) {
file.page.component = component; file.page.component = component;
this.push(file); this.push(file);
@ -415,7 +414,7 @@ gulp.task('pages', ['components'], function() {
/** /**
* Copies assets from MDL and _assets directory. * Copies assets from MDL and _assets directory.
*/ */
gulp.task('assets', function () { gulp.task('assets', function() {
return gulp.src([ return gulp.src([
'docs/_assets/**/*', 'docs/_assets/**/*',
'node_modules/clippy/build/clippy.swf', 'node_modules/clippy/build/clippy.swf',
@ -456,7 +455,7 @@ function watch() {
/** /**
* Serves the landing page from "out" directory. * Serves the landing page from "out" directory.
*/ */
gulp.task('serve:browsersync', function () { gulp.task('serve:browsersync', function() {
browserSync({ browserSync({
notify: false, notify: false,
server: { server: {
@ -554,7 +553,7 @@ gulp.task('pushCodeFiles', function() {
])); ]));
}); });
gulp.task('publish:code', function (cb) { gulp.task('publish:code', function(cb) {
runSequence( runSequence(
['zip:mdl', 'zip:templates'], ['zip:mdl', 'zip:templates'],
'genCodeFiles', 'genCodeFiles',