Skip to content

Latest commit

 

History

History
99 lines (69 loc) · 2.44 KB

README.md

File metadata and controls

99 lines (69 loc) · 2.44 KB

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

Param Type Description
path string path of .vue file

vuetojs.generateCode

generate js code with appointed mode from single .vue file

Param Type Description
path string path of .vue file
mode string output mode, one of amd/umd/global/commonjs

vuetojs.compile

compile .vue file to .js file

Param Type Description
options Object compile options
options.resource string path of .vue file, glob pattern
options.dest string directory of the compiled js files
options.mode string output mode, one of amd/umd/global/commonjs

Todo

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

License

MIT