Skip to content
This repository has been archived by the owner on Dec 26, 2018. It is now read-only.

Gulp 4 + Watchify does not apply vueify #225

Open
MidnightPolaris opened this issue Mar 24, 2018 · 1 comment
Open

Gulp 4 + Watchify does not apply vueify #225

MidnightPolaris opened this issue Mar 24, 2018 · 1 comment

Comments

@MidnightPolaris
Copy link

I am doing some simple tests on using Gulp and Watchify for Vue projects when I run into a problem where Watchify triggers a rebundle but the resulting bundle.js gives an error when run. Further investigation indicates when rebundling the <script> of the Vue component is not included in the bundle. This only happens when Watchify triggers a rebundle but not during initial bundling using the default task or running the js task directly.

gulpfile.js

var browserify = require('browserify')
var watchify = require('watchify')
var gulp = require('gulp')
var source = require('vinyl-source-stream')
var buffer = require('vinyl-buffer')
var uglify = require('gulp-uglify')
var sourcemaps = require('gulp-sourcemaps')
var rename = require("gulp-rename")

const b = browserify({
	entries: './index.js',
	debug: true,
	cache: {},
	packageCache: {},
})

gulp.task('js', function(){
	return b
		.transform('babelify', {presets: ['env']})
		.transform('vueify')
	.bundle()
		.pipe(source('bundle.js'))
		.pipe(buffer())
		.pipe(sourcemaps.init({loadMaps: true}))
		.pipe(uglify())
		.on('error', console.log.bind(console))
		.pipe(sourcemaps.write('./'))
		.pipe(gulp.dest('./'))
});

gulp.task('watch', function(){
	b.plugin(watchify)
	b.on('update', gulp.series('js'))
	return Promise.resolve(true)
})

gulp.task('default', gulp.series('watch', 'js'))

index.js

var Vue = require('vue')
var App = require('./App.vue')

new Vue({
	el: '#app',
	render: h => h(App)
})

App.vue

<template>
	<div id="app" class="container">
		<h2 class="display-2">{{ msg }}</h2>
	</div>
</template>

<script>
	module.exports = {
		data: () => ({
			msg: 'Hello World'
		})
	}
</script>

<style scoped>
</style>
@francarmona
Copy link

I have got the same issue

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants