美文网首页
vuecli4 一个工程 打包成多个项目

vuecli4 一个工程 打包成多个项目

作者: 我就是看看哦 | 来源:发表于2020-01-21 15:25 被阅读0次

    1、创建一个项目

    vue create hello-world
    cd hello-world
    yarn serve
    

    2、创建vue.config.js 文件
    要打包成2个项目分别是A项目和B项目

    const IS_PROD = ['production', 'prod'].includes(process.env.NODE_ENV);
    let appName =  process.argv.slice(0).reverse()[0].replace('--', '');
    let outputPath = appName === 'B?'B':'A'
    console.log(appName)
    module.exports = {
        publicPath: IS_PROD?'../'+outputPath+'/':'./',
        outputDir: 'dist/'+outputPath,
        assetsDir: 'static',
        lintOnSave: true,
        runtimeCompiler:true,
        productionSourceMap: true,
        pages: {
            index: {
                entry: 'src/views/' + appName + '/main.js',
            }
        },
        
    }
    

    3、创建项目路径


    项目A和B

    4、package.json 配置


    配置项目A和B

    5、编译和打包
    npm run serve_A 运行A项目
    npm run serve_B 运行B项目

    npm run build_A 打包A项目
    npm run build_B 打包B项目

    打包后文件路径

    相关文章

      网友评论

          本文标题:vuecli4 一个工程 打包成多个项目

          本文链接:https://www.haomeiwen.com/subject/arfezctx.html