Skip to content

Commit

Permalink
Improved bundler
Browse files Browse the repository at this point in the history
  • Loading branch information
sergeche committed Jan 5, 2015
1 parent 7bd0f98 commit c5b8d31
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 2 deletions.
22 changes: 20 additions & 2 deletions gulpfile.js
Expand Up @@ -12,7 +12,7 @@ var DEST = './dist';

function ciuWrapper() {
var buf = new Buffer('');
return through(function(chunk, end, next) {
return through(function(chunk, enc, next) {
buf += chunk;
next();
}, function(next) {
Expand All @@ -31,7 +31,8 @@ function bundle() {
return browserify({
entries: files,
detectGlobals: false,
standalone: 'emmet'
standalone: 'emmet',
fullPaths: true
})
.transform(function(file) {
if (path.basename(file) === 'caniuse.json') {
Expand All @@ -40,6 +41,23 @@ function bundle() {
return through();
})
.bundle()
.pipe(trimPath(path.join(__dirname, 'lib/')));
}

function escapeRegExp(str) {
return str.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g, '\\$&');
}

function trimPath(base) {
var buf = new Buffer('');
var reBase = new RegExp(escapeRegExp(base), 'g');
return through(function(chunk, enc, next) {
buf += chunk;
next();
}, function(next) {
this.push(buf.toString().replace(reBase, ''));
next();
});
}

// "App" version of Emmet: does not include snippets.json and caniuse.json,
Expand Down
1 change: 1 addition & 0 deletions lib/emmet.js
Expand Up @@ -271,6 +271,7 @@ define(function(require, exports, module) {
require: require,

// expose some useful data for plugin authors
file: file,
preferences: preferences,
resources: resources,
profile: profile,
Expand Down

0 comments on commit c5b8d31

Please sign in to comment.