Permalink
Browse files

Improved bundler

  • Loading branch information...
1 parent 7bd0f98 commit c5b8d310629d7e02590d2ee59f1766050860f879 @sergeche sergeche committed Jan 5, 2015
Showing with 21 additions and 2 deletions.
  1. +20 −2 gulpfile.js
  2. +1 −0 lib/emmet.js
View
@@ -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) {
@@ -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') {
@@ -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,
View
@@ -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,

0 comments on commit c5b8d31

Please sign in to comment.