0.9.4 • Published 7 years ago

vue-to-js v0.9.4

Weekly downloads
7
License
MIT
Repository
github
Last release
7 years ago

vue-to-js

NPM version Downloads Build Status Coverage Status

A simple cli for transforming .vue to .js

Installation

Prerequisites: Node.js (>=6.x, 6.x preferred).

$ npm install -g vue-to-js

Usage

  Usage: vuetojs [options]

  Options:

    -h, --help             output usage information
    -V, --version          output the version number
    -r, --resource [path]  .vue file
    -d, --dest [path]      output directory
    -m, --mode [type]      output mode, one of amd/umd/global/commonjs

Example:

$ vuetojs -r src/*.vue -d output -m amd

Lib

vue-to-js can also be used as a nodejs lib. Look at the example below for more information.

var vuetojs = require('vue-to-js');
var path = require('path');

var code = vuetojs.generateCode(path.resolve(__dirname, 'src/index.vue'), 'amd');
console.log(code);

vuetojs.compile({
    resource: 'src/*.vue',
    dest: 'dest',
    mode: 'amd'
});

API

vuetojs.getBlocks

get all blocks code from .vue file

ParamTypeDescription
pathstringpath of .vue file

vuetojs.generateCode

generate js code with appointed mode from single .vue file

ParamTypeDescription
pathstringpath of .vue file
modestringoutput mode, one of amd/umd/global/commonjs

vuetojs.compile

compile .vue file to .js file

ParamTypeDescription
optionsObjectcompile options
options.resourcestringpath of .vue file, glob pattern
options.deststringdirectory of the compiled js files
options.modestringoutput mode, one of amd/umd/global/commonjs

Todo

  • beautify output js
  • support source map
  • support template engine
  • support css preprocessor

License

MIT