Vue CLI's type checking service ignores memory limits

后端 未结 3 1804
忘掉有多难
忘掉有多难 2021-02-07 13:05

DevOps has requested that we limit our frontend builds to ~1GB of RAM, so that our Jenkins instance doesn\'t shut down. We use a standard @vue/cli project, with Typ

3条回答
  •  青春惊慌失措
    2021-02-07 13:23

    in vue.config.js

    const ForkTsCheckerWebpackPlugin = require('fork-ts-checker-webpack-plugin');
    const os=require('os');
    module.exports = {
        //......,
        chainWebpack: config => {
            config
                .plugin('fork-ts-checker')
                .tap(args => {
                    let totalmem=Math.floor(os.totalmem()/1024/1024); //get OS mem size
                    let allowUseMem= totalmem>2500? 2048:1000;
                    // in vue-cli shuld args[0]['typescript'].memoryLimit
                    args[0].memoryLimit = allowUseMem;
                    return args
                })
        },
       //......
    }
    

提交回复
热议问题