Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
"babelify": "^6.3.0",
"brfs": "^1.4.1",
"browserify": "^11.1.0",
"browserify-shim": "^3.8.10",
"camelcase": "^1.2.1",
"capitalize": "^1.0.0",
"chalk": "^1.1.1",
Expand All @@ -32,6 +31,7 @@
"gulp-rename": "^1.2.2",
"gulp-streamify": "^1.0.2",
"gulp-uglify": "^1.4.1",
"gulp-umd": "^0.2.0",
"gulp-util": "^3.0.6",
"merge-stream": "^1.0.0",
"vinyl-source-stream": "^1.1.0",
Expand Down
14 changes: 7 additions & 7 deletions tasks/dist.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@ var del = require('del');
var gutil = require('gulp-util');
var less = require('gulp-less');
var rename = require('gulp-rename');
var shim = require('browserify-shim');
var source = require('vinyl-source-stream');
var streamify = require('gulp-streamify');
var uglify = require('gulp-uglify');
var umd = require('gulp-umd');
var minifyCSS = require('gulp-minify-css');

module.exports = function (gulp, config) {
Expand All @@ -21,18 +21,18 @@ module.exports = function (gulp, config) {
})
.transform(babelify.configure({
plugins: [require('babel-plugin-object-assign')]
}))
.transform(shim);

config.component.dependencies.forEach(function (pkg) {
standalone.exclude(pkg);
});
}));

return standalone.bundle()
.on('error', function (e) {
gutil.log('Browserify Error', e);
})
.pipe(source(config.component.pkgName + '.js'))
.pipe(umd({
dependencies: function(file){
return config.component.dependencies;
}
}))
.pipe(gulp.dest(config.component.dist))
.pipe(rename(config.component.pkgName + '.min.js'))
.pipe(streamify(uglify()))
Expand Down
27 changes: 13 additions & 14 deletions tasks/examples.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,22 +7,27 @@ var del = require('del');
var gutil = require('gulp-util');
var less = require('gulp-less');
var merge = require('merge-stream');
var shim = require('browserify-shim');
var source = require('vinyl-source-stream');
var umd = require('gulp-umd');
var watchify = require('watchify');

module.exports = function (gulp, config) {
function doBundle (target, name, dest) {
function doBundle (target, name, dest, dependencies) {
return target.bundle()
.on('error', function (e) {
gutil.log('Browserify Error', e);
})
.pipe(source(name))
.pipe(umd({
dependencies: function(file){
return dependencies;
}
}))
.pipe(gulp.dest(dest))
.pipe(connect.reload());
}

function watchBundle (target, name, dest) {
function watchBundle (target, name, dest, dependencies) {
return watchify(target)
.on('update', function (scriptIds) {
scriptIds = scriptIds
Expand All @@ -35,7 +40,7 @@ module.exports = function (gulp, config) {
gutil.log(scriptIds[0] + ' updated, rebuilding...');
}

doBundle(target, name, dest);
doBundle(target, name, dest, dependencies);
})
.on('time', function (time) {
gutil.log(chalk.green(name + ' built in ' + (Math.round(time / 10) / 100) + 's'));
Expand Down Expand Up @@ -65,7 +70,6 @@ module.exports = function (gulp, config) {
plugins: [require('babel-plugin-object-assign')]
}));
config.aliasify && standalone.transform(aliasify);
standalone.transform(shim);
}

var examples = config.example.scripts.map(function (file) {
Expand All @@ -85,11 +89,6 @@ module.exports = function (gulp, config) {

config.component.dependencies.forEach(function (pkg) {
common.require(pkg);
bundle.exclude(pkg);
if (standalone) standalone.exclude(pkg);
examples.forEach(function (eg) {
eg.bundle.exclude(pkg);
});
});

if (dev) {
Expand All @@ -102,16 +101,16 @@ module.exports = function (gulp, config) {
}

var bundles = [
doBundle(common, 'common.js', dest),
doBundle(bundle, 'bundle.js', dest)
doBundle(common, 'common.js', dest, config.component.dependencies),
doBundle(bundle, 'bundle.js', dest, config.component.dependencies)
];

if (standalone) {
bundles.push(doBundle(standalone, 'standalone.js', dest));
bundles.push(doBundle(standalone, 'standalone.js', dest, config.component.dependencies));
}

return merge(bundles.concat(examples.map(function (eg) {
return doBundle(eg.bundle, eg.file, dest);
return doBundle(eg.bundle, eg.file, dest, config.component.dependencies);
})));
};
}
Expand Down