Vue 编译 INFO Starting

阅读: 评论:0

Vue 编译 INFO Starting

Vue 编译 INFO Starting

Vue运行日志输出:

 INFO Starting

 Starting type

 Using 1 worker with 2048MB memory limit

 

运行日志

问题: 运行vue项目,使用2G内存,不知道如何更改。

DevOps 要求将前端生成限制为 1GB 的 RAM,防止 Jenkins 实例被关闭。使用标准Vue Cli创建项目,带 TypeScript。但是,TS 类型检查服务会忽略限制其内存使用的所有尝试,这始终为 2048 MB。@vue/cli

 

禁用它, 但这引入了其他问题。fork-ts-checker-webpack-plugin

$ NODE_OPTIONS=--max_old_space_size=1024 NODE_ENV=production node --max_old_space_size=1024 --max-old-space-size=1024 node_modules/.bin/vue-cli-service build

类型检查不生效,始终是2048 MB 。


解决方式:

  • 自定义 Vue CLI 的内置功能来修改 配置:ForkTsCheckerWebpackPlugin`&#fig
// fig.js
​
const ForkTsCheckerWebpackPlugin = require('fork-ts-checker-webpack-plugin');
​
ports = {configureWebpack: config => {
​// get a reference to the existing ForkTsCheckerWebpackPluginconst existingForkTsChecker = config.plugins.filter(p => p instanceof ForkTsCheckerWebpackPlugin,)[0];
​// remove the existing ForkTsCheckerWebpackPlugin// so that we can replace it with our modified versionconfig.plugins = config.plugins.filter(p => !(p instanceof ForkTsCheckerWebpackPlugin),);
​// copy the options from the original ForkTsCheckerWebpackPlugin// instance and add the memoryLimit propertyconst forkTsCheckerOptions = existingForkTsChecker.Limit = 4096;
​config.plugins.push(new ForkTsCheckerWebpackPlugin(forkTsCheckerOptions));},
};

 

info输出:Starting type 
Using 1 worker with 4096MB memory limit

有关选项的信息, 请参阅此处:configurewebpack

若要查看 Vue CLI 使用的默认 Webpack 配置,vue webpack config


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

node_modules/fork-ts-checker-webpack-plugin/lib/index.js

declare class ForkTsCheckerWebpackPlugin {static readonly DEFAULT_MEMORY_LIMIT = 4096;static readonly ONE_CPU = 1;static readonly ALL_CPUS: number;static readonly ONE_CPU_FREE: number;static readonly TWO_CPUS_FREE: number;readonly options: Partial<Options>;

参考链接

本文发布于:2024-01-28 04:02:49,感谢您对本站的认可!

本文链接:https://www.4u4v.net/it/17063857964635.html

版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。

标签:INFO   Vue   Starting   server   development
留言与评论(共有 0 条评论)
   
验证码:

Copyright ©2019-2022 Comsenz Inc.Powered by ©

网站地图1 网站地图2 网站地图3 网站地图4 网站地图5 网站地图6 网站地图7 网站地图8 网站地图9 网站地图10 网站地图11 网站地图12 网站地图13 网站地图14 网站地图15 网站地图16 网站地图17 网站地图18 网站地图19 网站地图20 网站地图21 网站地图22/a> 网站地图23