lib/index.js
function generateCode(filepath) {
    var mode = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 'amd';


    // support 4 types of output as follows:
    // amd/commonjs/global/umd
    var choice = {
        amd: {
            prefix: 'define([\'module\', \'exports\'], function (module, exports) {',
            suffix: '});'
        },
        commonjs: {
            prefix: '',
            suffix: ''
        },
        global: {
            prefix: '(function (module, exports) {',
            suffix: '})(this, this.exports = this.exports || {});'
        },
        umd: {
            prefix: '\n                (function (global, factory) {\n                    typeof exports === \'object\' && typeof module !== \'undefined\' ? factory(module, exports) :\n                    typeof define === \'function\' && define.amd ? define([\'module\', \'exports\'], factory) :\n                    (factory(global, global.exports = global.exports || {}));\n                }(this, (function (module, exports) {\n            ',
            suffix: '})));'

        }
    };

    var _ref = choice[mode] || choice.amd,
        prefix = _ref.prefix,
        suffix = _ref.suffix;
    //const content = readFileSync(filepath, 'utf8');
    //const result = parseComponent(content);


    var result = getBlocks(filepath);
    var templateCode = result.template.code;
    var styleCode = result.styles.map(function (style) {
        return (0, _style2.default)(style.code);
    }).join('\n');
    var scriptCode = result.script.code;

    var code = '\n        ' + prefix + '\n            /* append style */\n            ' + styleCode + '\n\n            /* get render function */\n            var _module1 = {\n                exports: {}\n            };\n            (function (module, exports) {\n                ' + (0, _template2.default)(templateCode) + '\n            })(_module1, _module1.exports);\n\n            /* get script output data */\n            var _module2 = {\n                exports: {}\n            };\n            (function (module, exports) {\n                ' + (0, _script2.default)(scriptCode) + '\n            })(_module2, _module2.exports);\n\n            var obj = _module2.exports.default || _module2.exports;\n            obj.render = _module1.exports.render;\n            obj.staticRenderFns = _module1.exports.staticRenderFns;\n\n            module.exports = obj;\n        ' + suffix + '\n    ';

    return (0, _jsBeautify.js_beautify)(code);
}
function generateCode(filepath) {
    var mode = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 'amd';


    // support 4 types of output as follows:
    // amd/commonjs/global/umd
    var choice = {
        amd: {
            prefix: 'define([\'module\', \'exports\'], function (module, exports) {',
            suffix: '});'
        },
        commonjs: {
            prefix: '',
            suffix: ''
        },
        global: {
            prefix: '(function (module, exports) {',
            suffix: '})(this, this.exports = this.exports || {});'
        },
        umd: {
            prefix: '\n                (function (global, factory) {\n                    typeof exports === \'object\' && typeof module !== \'undefined\' ? factory(module, exports) :\n                    typeof define === \'function\' && define.amd ? define([\'module\', \'exports\'], factory) :\n                    (factory(global, global.exports = global.exports || {}));\n                }(this, (function (module, exports) {\n            ',
            suffix: '})));'

        }
    };

    var _ref = choice[mode] || choice.amd,
        prefix = _ref.prefix,
        suffix = _ref.suffix;
    //const content = readFileSync(filepath, 'utf8');
    //const result = parseComponent(content);


    var result = getBlocks(filepath);
    var templateCode = result.template.code;
    var styleCode = result.styles.map(function (style) {
        return (0, _style2.default)(style.code);
    }).join('\n');
    var scriptCode = result.script.code;

    var code = '\n        ' + prefix + '\n            /* append style */\n            ' + styleCode + '\n\n            /* get render function */\n            var _module1 = {\n                exports: {}\n            };\n            (function (module, exports) {\n                ' + (0, _template2.default)(templateCode) + '\n            })(_module1, _module1.exports);\n\n            /* get script output data */\n            var _module2 = {\n                exports: {}\n            };\n            (function (module, exports) {\n                ' + (0, _script2.default)(scriptCode) + '\n            })(_module2, _module2.exports);\n\n            var obj = _module2.exports.default || _module2.exports;\n            obj.render = _module1.exports.render;\n            obj.staticRenderFns = _module1.exports.staticRenderFns;\n\n            module.exports = obj;\n        ' + suffix + '\n    ';

    return (0, _jsBeautify.js_beautify)(code);
}
function generateCode ( filepath ) { var mode = arguments . length > 1 && arguments [ 1 ] !== undefined ? arguments [ 1 ] : 'amd' ; // support 4 types of output as follows: // amd/commonjs/global/umd var choice = { amd : { prefix : 'define([\'module\', \'exports\'], function (module, exports) {' , suffix : '});' } , commonjs : { prefix : '' , suffix : '' } , global : { prefix : '(function (module, exports) {' , suffix : '})(this, this.exports = this.exports || {});' } , umd : { prefix : '\n                (function (global, factory) {\n                    typeof exports === \'object\' && typeof module !== \'undefined\' ? factory(module, exports) :\n                    typeof define === \'function\' && define.amd ? define([\'module\', \'exports\'], factory) :\n                    (factory(global, global.exports = global.exports || {}));\n                }(this, (function (module, exports) {\n            ' , suffix : '})));' } } ; var _ref = choice [ mode ] || choice . amd , prefix = _ref . prefix , suffix = _ref . suffix ; //const content = readFileSync(filepath, 'utf8'); //const result = parseComponent(content); var result = getBlocks ( filepath ) ; var templateCode = result . template . code ; var styleCode = result . styles . map ( function ( style ) { return ( 0 , _style2 . default ) ( style . code ) ; } ) . join ( '\n' ) ; var scriptCode = result . script . code ; var code = '\n        ' + prefix + '\n            /* append style */\n            ' + styleCode + '\n\n            /* get render function */\n            var _module1 = {\n                exports: {}\n            };\n            (function (module, exports) {\n                ' + ( 0 , _template2 . default ) ( templateCode ) + '\n            })(_module1, _module1.exports);\n\n            /* get script output data */\n            var _module2 = {\n                exports: {}\n            };\n            (function (module, exports) {\n                ' + ( 0 , _script2 . default ) ( scriptCode ) + '\n            })(_module2, _module2.exports);\n\n            var obj = _module2.exports.default || _module2.exports;\n            obj.render = _module1.exports.render;\n            obj.staticRenderFns = _module1.exports.staticRenderFns;\n\n            module.exports = obj;\n        ' + suffix + '\n    ' ; return ( 0 , _jsBeautify . js_beautify ) ( code ) ; }
compile vue file to js code

@param {string} filepath the path of .vue file
@param {string} mode the output mode, it should be
one of amd/commonjs/global/umd
@return {string} js code with appointed mode
compile vue file to js code