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']}) // path to your entry file here
    .transform(vueify)
    .plugin('vueify/plugins/extract-css', { out: './tmp/css/bundle.css' }) // path to where you want your css
    .transform(babelify, {"presets": ["es2015"]})
    .external('vue') // remove vue from the bundle, if you omit this line whole vue will be bundled with your code
    .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']}) // path to your entry file here
    .transform(vueify)
    .plugin('vueify/plugins/extract-css', { out: './dist/css/bundle.css' }) // path to where you want your css
    .transform(babelify, {"presets": ["es2015"]})
    .transform(uglifyify, {global: true}) // of course if you want to use this transform
    .external('vue') // remove vue from the bundle, if you omit this line whole vue will be bundled with your code
    .bundle()
    .pipe(source('bundle.js'))
    .pipe(buffer()) // you have to use it if you want to use more pipes
    .pipe(uglify()) // This is different from uglifyify transform. I am using both
    .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"
 }