Tag: gulp browserify babeljs

用Gulp输出缩小版本和非缩小版本

我在Gulpfile.js中有这个打包器,它运行良好: var compile = (watch) => { var bundler = watchify(browserify('./src/index.js', { debug: true }).transform(babel)); var rebundle = () => { bundler.bundle() .on('error', function(err) { console.error(err); this.emit('end'); }) .pipe(source('lib.js')) .pipe(buffer()) .pipe(sourcemaps.init({ loadMaps: true })) .pipe(sourcemaps.write('./')) .pipe(gulp.dest('./dist/')); }; if (watch) { bundler.on('update', function() { console.log('-> bundling…'); rebundle(); }); } rebundle(); }; 这给了我:arli.js和arli.js.map 但是当试图丑化它像这样: var compile = […]

Browserify转换+ sourcemaps之间的区别当通过CLI运行时编程方式在Gulpfile?

我有一个使用Babelify变换的项目。 在我的NPM运行脚本中,使用Watchify有一个很好的工作stream程: package.json snippet – "scripts": { "watch": "NODE_ENV=DEV watchify -d -e js/main.js -o dist/js/main.js -v" }, "main": "js/main.js", "browserify": { "transform": [ "babelify", "envify" ] } // npm run watch 现在,我试图转移到Gulp来简化我的构build周期,但是当我以编程方式触发watchify / browserify转换和构build时,我似乎无法实现相同的捆绑JS文件。 这是我在我的gulpfile.js中尝试的: function createBundle(file) { var bundle = watchify(browserify({ entries: file.input, transform: [ babelify, envify({NODE_ENV: process.env.NODE_ENV}) ], debug: true, cache: {}, packageCache: […]