gulp-vue-compiler

Vue single file component compiler plugin for Gulp
1,036 13
Install
npm install gulp-vue-compiler@0.0.1
Latest Version:0.0.1
Vue:2
License:MIT
Last Updated:May 10, 2021
Links: GitHub  ·  npm
Maintainer: frankdiox

gulp-vue-compiler

This plugin compiles Vue single file components (SFC) to plain JavaScript.

Installation

npm install gulp-vue-compiler --save-dev

Any other plugin or dependency such as babel-core should be installed as well.

Usage

var vueCompiler = require('gulp-vue-compiler');

gulp.task('vue-compile', function() {
  return gulp.src('components/**/*.vue')
    .pipe(vueCompiler({ /* options */ }))
    .pipe(gulp.dest('./dist/'));
});

Implementation details and options

  • options.newExtension: Optionally modifies the output files extension to the new string.

  • v0: Vueify's API is used internally. Therefore, any valid option for Vueify is valid here as well. See Vueify options here. Additionally, options.ESModules boolean option is available for removing the closure that Vueify adds automatically (which breaks ES modules). Passing modules: false in Babel's env preset automatically activates this option.

  • v1: Uses vue-component-compiler internally (more info here). options.esModule (default true), options.parserConfig, options.templateCompilerConfig, options.babel. Beta release does not support style tags.

Examples

  • Compiling *.vue components to plain JavaScript using Babel and ES modules:
return gulp.src('components/**/*.vue')
  .pipe(vueCompiler({
    newExtension: 'js', // *.vue => *.js
    babel: {
      babelrc: false,
      presets: [
        ['env', {
          modules: false, // Keep ES modules in 'script' tag
          targets: {
            browsers: [ '> 1%', 'last 2 versions' ]
          }
        }],
        'stage-3'
      ]
    }
  }))
  .pipe(gulp.dest('./dist/'));

Related Packages

@vizejs/vite-plugin

High-performance native Vite plugin for Vue SFC compilation powered by Vize

113,453 909
@vizejs/rspack-plugin

High-performance Rspack plugin for Vue SFC compilation powered by Vize

60,208 908
@intlayer/babel

A Babel plugin for Intlayer that transforms declaration files and provides inter...

486,447 856
vue-inheritance-loader

Loader to provide template inheritance in Vue's Single File Components

1,154 37
@21cnfe/onekit-mp-cli

小程序框架开发工具

1,063

Version History

Version Released License
0.0.1 MIT
Pre-releases (2)
Version Released License
1.0.0-beta.1 MIT
1.0.0-beta.0 MIT