Skip to content
This repository has been archived by the owner on Mar 22, 2018. It is now read-only.

Commit

Permalink
Bump version
Browse files Browse the repository at this point in the history
  • Loading branch information
Florian Rey committed Sep 17, 2014
1 parent e005762 commit 653910b
Show file tree
Hide file tree
Showing 5 changed files with 70 additions and 41 deletions.
85 changes: 51 additions & 34 deletions assets.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,11 @@ var
pattern: 'src/**/*Bundle/Resources/assets'
}
],
includes: [
dest: 'web/assets',
vendors: [
'bower_components',
'node_modules'
],
dest: 'web/assets',
header: false,
autoprefixer: {},
assets: {
Expand All @@ -62,6 +62,9 @@ var
},
files: {
groups: {}
},
vendors: {
src: 'vendors'
}
}
};
Expand Down Expand Up @@ -132,51 +135,55 @@ Assets.prototype = {
assetGroup = (typeof(group.name) == 'function') ? group.name(assetGroupPath) : group.name;

this.assets[assetType][assetGroup] = {
src: path.resolve(assetGroupPath + '/' + this.options.assets[assetType].glob),
srcWatch: path.resolve(assetGroupPath + '/' + this.options.assets[assetType].globWatch),
src: path.resolve(assetGroupPath + (this.options.assets[assetType].glob ? '/' + this.options.assets[assetType].glob : '')),
dest: this.getDest(assetType)
};

this.assets[assetType][assetGroup].srcWatch = this.options.assets[assetType].globWatch ? path.resolve(assetGroupPath + '/' + this.options.assets[assetType].globWatch) : this.assets[assetType][assetGroup].src;

if (util.env.verbose) {
util.log(
'Found group', "'" + util.colors.cyan(assetGroup) + "'",
"'" + util.colors.grey(assetType) + "'",
'at', util.colors.magenta(assetGroupPath + '/' + this.options.assets[assetType].glob),
'watching', util.colors.magenta(assetGroupPath + '/' + this.options.assets[assetType].globWatch)
'Found', util.colors.grey(assetType),
'group', "'" + util.colors.cyan(assetGroup) + "'",
'at', util.colors.magenta(this.assets[assetType][assetGroup].src),
'watching', util.colors.magenta(this.assets[assetType][assetGroup].srcWatch)
);
}
}.bind(this));
}.bind(this));
}

// Add custom groups
Object.keys(this.options.assets[assetType].groups).forEach(function(assetGroup) {

var
assetGroupSrc = [this.options.assets[assetType].groups[assetGroup].src];

this.options.includes.forEach(function(include) {
assetGroupSrc.push(include + '/' + assetGroupSrc[0]);
});

assetGroupSrc.forEach(function(src) {
if (glob.sync(src).length) {

this.assets[assetType][assetGroup] = {
src: path.resolve(src),
dest: this.getDest(assetType) + (this.options.assets[assetType].groups[assetGroup].dest ? '/' + this.options.assets[assetType].groups[assetGroup].dest : '')
};

if (util.env.verbose) {
util.log(
'Custom group', "'" + util.colors.cyan(assetGroup) + "'",
"'" + util.colors.grey(assetType) + "'",
'at', util.colors.magenta(src)
);
if (this.options.assets[assetType].groups) {
Object.keys(this.options.assets[assetType].groups).forEach(function(assetGroup) {

var
assetGroupSrc = [this.options.assets[assetType].groups[assetGroup].src];

this.getVendors().forEach(function(vendor) {
assetGroupSrc.push(vendor + '/' + assetGroupSrc[0]);
});

assetGroupSrc.forEach(function(src) {
if (glob.sync(src).length) {

this.assets[assetType][assetGroup] = {
src: path.resolve(src),
dest: this.getDest(assetType) + (this.options.assets[assetType].groups[assetGroup].dest ? '/' + this.options.assets[assetType].groups[assetGroup].dest : ''),
concat: this.options.assets[assetType].groups[assetGroup].concat ? this.options.assets[assetType].groups[assetGroup].concat : false
};

if (util.env.verbose) {
util.log(
'Custom', util.colors.grey(assetType),
'group', "'" + util.colors.cyan(assetGroup) + "'",
'at', util.colors.magenta(src)
);
}
}
}
}.bind(this));
}.bind(this));
}.bind(this));
}
}

// Filter on current asset group
Expand Down Expand Up @@ -260,10 +267,20 @@ Assets.prototype = {
return this.options.dest + (this.options.assets[assetType].dest ? '/' + this.options.assets[assetType].dest : '');
}

// Asset type & grou dest
// Asset type & group dest
return this.get(assetType)[assetGroup].dest;
},

// Get concat
getConcat: function(assetType, assetGroup) {
return this.get(assetType)[assetGroup].concat ? this.get(assetType)[assetGroup].concat : false;
},

// Get vendors
getVendors: function() {
return this.options.vendors.concat(this.getSrc('vendors'));
},

// Get header
getHeader: function() {
return this.options.header;
Expand Down
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "elao-assets-gulp",
"description": "Handle your project's assets with style ! (and gulp)",
"version": "0.1.5",
"version": "0.1.6",
"homepage": "https://github.com/Elao/node-module-assets-gulp",
"repository": {
"type": "git",
Expand Down Expand Up @@ -36,6 +36,7 @@
"gulp-size": "1.1.*",
"gulp-notify": "1.6.*",
"gulp-header": "1.1.*",
"gulp-concat": "2.4.*",
"require-dir": "0.1.*",
"event-stream": "3.1.*",
"through2": "0.6.*",
Expand Down
16 changes: 13 additions & 3 deletions tasks/files.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,18 +9,28 @@ gulp.task('files', function() {
tasks = [];

Object.keys(assets.get('files')).forEach(function(assetGroup) {

var
assetGroupSrc = assets.getSrc('files', assetGroup),
assetGroupDest = assets.getDest('files', assetGroup)
assetGroupConcat = assets.getConcat('files', assetGroup);

tasks.push(
gulp.src(assets.getSrc('files', assetGroup))
gulp.src(assetGroupSrc)
.pipe(plugins.plumber())
.pipe(plugins.if(
plugins.util.env.dev || false,
plugins.changed(assets.getDest('files', assetGroup))
plugins.changed(assetGroupDest)
))
.pipe(plugins.if(
assetGroupConcat ? true : false,
plugins.concat(assetGroupConcat ? assetGroupConcat : 'foo')
))
.pipe(plugins.if(
plugins.util.env.verbose || false,
plugins.size({showFiles: true})
))
.pipe(gulp.dest(assets.getDest('files', assetGroup)))
.pipe(gulp.dest(assetGroupDest))
);
});

Expand Down
5 changes: 3 additions & 2 deletions tasks/js.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ function bundle(asset, base, dest, watch) {
bundler = browserify(
asset, {
debug: plugins.util.env.dev || false,
paths: assets.getVendors(),
// Watchify
cache: {},
packageCache: {},
Expand All @@ -18,8 +19,8 @@ function bundle(asset, base, dest, watch) {
),
transform = function() {
var
path = require('path'),
source = require('vinyl-source-stream');
path = require('path'),
source = require('vinyl-source-stream');

return bundler
.bundle()
Expand Down
2 changes: 1 addition & 1 deletion tasks/sass.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ gulp.task('sass', function() {
.pipe(plugins.plumber())
.pipe(plugins.sass({
errLogToConsole: true,
includePaths: assets.options.includes,
includePaths: assets.getVendors(),
outputStyle: (plugins.util.env.dev || false) ? 'nested' : 'compressed',
precision: 10,
sourceComments: (plugins.util.env.dev || false) ? 'map' : 'none'
Expand Down

0 comments on commit 653910b

Please sign in to comment.