src/index.js
function convertToJSContent(script, template, style, fileName, filePath) {

    if (!script) {
        return "";
    }

    //兼容 windows
    filePath = filePath.replace(/\\/g, "/");

    let jsFileContent = `(function(global, Vue, undefined){
    if(!global.__FORGE_ES6_VUE_COMPONENTS__) {
        global.__FORGE_ES6_VUE_COMPONENTS__ = {};
    }
`;


    if (style && style.length > 0) {
        jsFileContent += `
    (function(){
        function getCurrentScriptBase() {
            var src,
                lidx,
                scripts;
            
            if (document.currentScript) {
                src = document.currentScript.src;
            } else {
                scripts = document.getElementsByTagName('script');
                src = scripts[scripts.length - 1].src;
            }
            
            lidx = src.lastIndexOf("/");
            
            return src.substring(0, lidx);
        }
        
        var styleLink = document.createElement('link');
        styleLink.rel = "stylesheet";
        styleLink.href = getCurrentScriptBase() + "/" + "` + fileName + `.css";
        document.head.appendChild(styleLink);
    }());\n`;
    }

    jsFileContent += processJavascript(fileName, script, processTemplate(template), style, filePath);

    jsFileContent += "\n\nglobal." + fileName + " = " + fileName + ";\n\n";

    //伪造ES6格式的VUE组件
    jsFileContent += "global.__FORGE_ES6_VUE_COMPONENTS__['" + filePath + "/" + fileName + ".vue']=" + fileName + ";\n";

    jsFileContent += "Vue.component('vue" + fileName.replace(/([A-Z])/g, "-$1").toLowerCase() + "', " + fileName + ");\n\n";

    jsFileContent += "\n}(window, Vue));";

    return jsFileContent;
}
function convertToJSContent(script, template, style, fileName, filePath) {

    if (!script) {
        return "";
    }

    //兼容 windows
    filePath = filePath.replace(/\\/g, "/");

    let jsFileContent = `(function(global, Vue, undefined){
    if(!global.__FORGE_ES6_VUE_COMPONENTS__) {
        global.__FORGE_ES6_VUE_COMPONENTS__ = {};
    }
`;


    if (style && style.length > 0) {
        jsFileContent += `
    (function(){
        function getCurrentScriptBase() {
            var src,
                lidx,
                scripts;
            
            if (document.currentScript) {
                src = document.currentScript.src;
            } else {
                scripts = document.getElementsByTagName('script');
                src = scripts[scripts.length - 1].src;
            }
            
            lidx = src.lastIndexOf("/");
            
            return src.substring(0, lidx);
        }
        
        var styleLink = document.createElement('link');
        styleLink.rel = "stylesheet";
        styleLink.href = getCurrentScriptBase() + "/" + "` + fileName + `.css";
        document.head.appendChild(styleLink);
    }());\n`;
    }

    jsFileContent += processJavascript(fileName, script, processTemplate(template), style, filePath);

    jsFileContent += "\n\nglobal." + fileName + " = " + fileName + ";\n\n";

    //伪造ES6格式的VUE组件
    jsFileContent += "global.__FORGE_ES6_VUE_COMPONENTS__['" + filePath + "/" + fileName + ".vue']=" + fileName + ";\n";

    jsFileContent += "Vue.component('vue" + fileName.replace(/([A-Z])/g, "-$1").toLowerCase() + "', " + fileName + ");\n\n";

    jsFileContent += "\n}(window, Vue));";

    return jsFileContent;
}
将vue文件中的内容，进行转换，生成多页引用的vue
@param script 脚本内容
@param template 模板内容
@param style 样式内容
@param fileName 文件名
@param filePath 文件路径
@returns {*}