Skip to content
This repository has been archived by the owner on Jul 7, 2023. It is now read-only.

Commit

Permalink
Updated API + all streams/tasks are back in 1 file to make loading fast
Browse files Browse the repository at this point in the history
  • Loading branch information
roeldev committed Feb 10, 2016
1 parent 650c8f9 commit 6e4c72f
Show file tree
Hide file tree
Showing 5 changed files with 87 additions and 107 deletions.
1 change: 1 addition & 0 deletions .npmignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
.jscsrc
.jshintrc

.maelstrom.yml
.travis.yml
appveyor.yml
gulpfile.js
Expand Down
92 changes: 86 additions & 6 deletions lib/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,32 +13,112 @@
*/
'use strict';

const _ = require('underscore');
const GulpAutoprefixer = require('gulp-autoprefixer');
const GulpConcat = require('gulp-concat');
const GulpCssNano = require('gulp-cssnano');
const GulpIf = require('gulp-if');

// // // // // // // // // // // // // // // // // // // // // // // // // // //

module.exports = function()
{
let $plugin = new this.Plugin(__filename, 'css',
const Maelstrom = this;
const Config = Maelstrom.config;
const Gulp = Maelstrom.gulp;
const Utils = Maelstrom.utils;

// -------------------------------------------------------------------------

let $plugin = new Maelstrom.Plugin(__filename, 'css',
{
/**
* Return the location of the Sass source files.
*/
src: function($src)
{
let $defaultSrc = this.maelstrom.config.src.css + '/**/*.css';
return this.maelstrom.utils.extendArgs($src, $defaultSrc);
let $defaultSrc = Config.src.css + '/**/*.css';
return Utils.extendArgs($src, $defaultSrc);
},

/**
* Return the location of the CSS output folder.
*/
dest: function()
{
return this.maelstrom.config.dest.css;
return Config.dest.css;
}
});

// -------------------------------------------------------------------------

/**
* Concatenate CSS files, autoprefix and minify the result when not `--dev`.
*/
$plugin.addStream('concat', function($destFile, $isProd)
{
// make sure the dest filename has a js file extension
if ($destFile && $destFile.substr($destFile.length - 4) !== '.css')
{
$destFile += '.css';
}

let $stream = GulpConcat($destFile);
$stream.pipe( $plugin.stream('css', [$isProd]) );

return $stream;
});

$plugin.readStreams();
$plugin.readTasks();
/**
* Autoprefix and further minify the result when not `--dev`.
*/
$plugin.addStream('css', function($isProd)
{
let $stream = GulpAutoprefixer(Config.css.autoprefixer);

// minify when in production mode
$stream.pipe( GulpIf(Utils.isProd() || $isProd, GulpCssNano()) );

return $stream;
});

// -------------------------------------------------------------------------

/**
*
*/
$plugin.addTask('css', function()
{
let $concat = Config.css.concat;

if (!_.isEmpty($concat))
{
for (let $destFile in $concat)
{
if (!$concat.hasOwnProperty($destFile))
{
continue;
}

let $srcFiles = $concat[$destFile];

Gulp.src($srcFiles)
.pipe( Maelstrom.stream('plumber') )
.pipe( self.stream('concat', [$destFile]) )
// .pipe( GulpSize(Config.main.size) )
.pipe( Maelstrom.stream('size') )
.pipe( Gulp.dest(self.dest()) );
}
}
});

/**
* Clean the CSS output dir from all excess files.
*/
$plugin.addTask('css:clean', function()
{
Maelstrom.stream('clean', Config.dest.css);
});

return $plugin;
};
30 changes: 0 additions & 30 deletions lib/streams/concat.js

This file was deleted.

29 changes: 0 additions & 29 deletions lib/streams/css.js

This file was deleted.

42 changes: 0 additions & 42 deletions lib/tasks/css.js

This file was deleted.

0 comments on commit 6e4c72f

Please sign in to comment.