首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Gulpfile不创建bundle.js

Gulpfile不创建bundle.js
EN

Stack Overflow用户
提问于 2016-06-19 00:15:07
回答 1查看 478关注 0票数 1

我的卷宗有点问题

代码语言:javascript
复制
"use strict"

var gulp = require("gulp")
var browserify = require("browserify")
var source = require("vinyl-source-stream")
var livereload = require('gulp-livereload')
var watchify = require('watchify')

gulp.task("default", () => {
    livereload.listen()
    var bundler = browserify("./src/components/index.jsx")
        .plugin(watchify, {ignoreWatch: './src/components/*'})
        .transform("babelify", {presets: ["es2015", "react"]})
    bundle(bundler)
    bundler.on('update', function () {
        bundle(bundler)
    })
})

function bundle(bundler) {

  bundler
    .bundle()
    .pipe(source('bundle.js')) // Set source name
    .pipe(gulp.dest("./public/dist"))
    .pipe(livereload()); // Reload the view in the browser
}

当我使用gulp执行它时,我得到以下消息

02:06:23使用gulpfile ~/rpi rpi/grapfile.js 02:06:23开始 “默认”。02:06:23在24 ms后完成“默认”

但是bundle.js不是创建的。有钥匙吗?提前感谢!

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2016-06-19 17:01:02

你为什么不试试这个?

代码语言:javascript
复制
function bundle(bundler) {  
    return bundler.bundle().on('error', function (err) {
        console.error(err.message)
        this.emit('end')
    })
    .pipe(source('bundle.js'))
    .pipe(buffer())
    .pipe(plugins.sourcemaps.init({ loadMaps: true }))
    .pipe(plugins.sourcemaps.write('./'))
    .pipe(gulp.dest('./public/dist/js/'))
    .pipe(plugins.livereload()) 
}

然后你就可以看到发生了什么

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/37902762

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档