国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 網(wǎng)站 > WEB開發(fā) > 正文

如何組織gulp文件

2024-04-27 15:17:03
字體:
供稿:網(wǎng)友

很詳細(xì)的gulp文件組織方式 https://www.freshconsulting.com/how-to-organize-your-gulp-js-development-builds-for-multiple-environments/

gulp-util,可以用來判斷環(huán)境變量,然后決定編譯方式

how to combination the browserify and the uglify? you need to convert the streaming vinyl file object given by source() with vinyl-buffer because gulp-uglify (and most gulp plugins) works on buffered vinyl file objects So you'd have this insteadvar browserify = require('browserify');var gulp = require('gulp');var uglify = require('gulp-uglify');var source = require('vinyl-source-stream');var buffer = require('vinyl-buffer');gulp.task('browserify', function() { return browserify('./source/scripts/app.js') .bundle() .pipe(source('bundle.js')) // gives streaming vinyl file object .pipe(buffer()) // <----- convert from streaming to buffered vinyl file object .pipe(uglify()) // now gulp-uglify works .pipe(gulp.dest('./build/scripts'));});Or, you can choose to use vinyl-transform instead which takes care of both streaming and buffered vinyl file objects for you, like sovar gulp = require('gulp');var browserify = require('browserify');var transform = require('vinyl-transform');var uglify = require('gulp-uglify');gulp.task('build', function () { // use `vinyl-transform` to wrap the regular ReadableStream returned by `b.bundle();` with vinyl file object // so that we can use it down a vinyl pipeline // while taking care of both streaming and buffered vinyl file objects var browserified = transform(function(filename) { // filename = './source/scripts/app.js' in this case return browserify(filename) .bundle(); }); return gulp.src(['./source/scripts/app.js']) // you can also use glob patterns here to browserify->uglify multiple files .pipe(browserified) .pipe(uglify()) .pipe(gulp.dest('./build/scripts'));});Both of the above recipes will achieve the same thing.Its just about how you want to manage your pipes (converting between regular NodeJS Streams and streaming vinyl file objects and buffered vinyl file objects)Edit: I've written a longer article regarding using gulp + browserify and different apPRoaches at: https://medium.com/@sogko/gulp-browserify-the-gulp-y-way-bb359b3f9623
發(fā)表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發(fā)表
主站蜘蛛池模板: 扶绥县| 和林格尔县| 资源县| 青田县| 易门县| 安义县| 马山县| 司法| 信阳市| 新和县| 锡林浩特市| 永济市| 涿州市| 休宁县| 镇雄县| 馆陶县| 元氏县| 凭祥市| 图木舒克市| 商水县| 彭山县| 开鲁县| 平原县| 合川市| 玉树县| 赤峰市| 南江县| 正安县| 巢湖市| 库伦旗| 陇川县| 武胜县| 延寿县| 浮山县| 吉林省| 湖北省| 新丰县| 蒙自县| 永康市| 康马县| 江口县|