how to compile single file component vuejs in gulp code example
Example 1: how to render file vue template in javascript with gulp
gulp.task('bundle-for-dev', function () {
return browserify({entries: ['./src/js/entry.js']})
.transform(vueify)
.plugin('vueify/plugins/extract-css', { out: './tmp/css/bundle.css' })
.transform(babelify, {"presets": ["es2015"]})
.external('vue')
.bundle()
.pipe(source('bundle.js'))
.pipe(gulp.dest('./tmp/js'));
})
Example 2: how to render file vue template in javascript with gulp
gulp.task('bundle-for-prod', function () {
return browserify({entries: ['./src/js/entry.js']})
.transform(vueify)
.plugin('vueify/plugins/extract-css', { out: './dist/css/bundle.css' })
.transform(babelify, {"presets": ["es2015"]})
.transform(uglifyify, {global: true})
.external('vue')
.bundle()
.pipe(source('bundle.js'))
.pipe(buffer())
.pipe(uglify())
.pipe(gulp.dest('./dist/js'));
})
Example 3: how to render file vue template in javascript with gulp
var babelify = require('babelify'),
browserify = require('browserify'),
buffer = require('vinyl-buffer'),
es = require('event-stream'),
gulp = require('gulp'),
source = require('vinyl-source-stream'),
uglify = require('gulp-uglify'),
uglifyify = require('uglifyify'),
vueify = require('vueify');
Example 4: how to render file vue template in javascript with gulp
"browser": {
"vue": "vue/dist/vue.common.js"
}