记录一次本地打包vue项目遇见的问题
内存溢出
FATAL ERROR: CALL_AND_RETRY_LAST Allocation failed - JavaScript heap out of memory
- Building for production... 1: 00007FF663BB4C9F napi_wrap+111007
2: 00007FF663B58226 v8::base::CPU::has_sse+59910
3: 00007FF663B59126 node::OnFatalError+294
4: 00007FF664432ABE v8::Isolate::ReportExternalAllocationLimitReached+94
5: 00007FF66441788D v8::SharedArrayBuffer::Externalize+781
6: 00007FF6642C09DC v8::internal::Heap::EphemeronKeyWriteBarrierFromCode+1516
7: 00007FF6642BBDD1 v8::internal::Heap::AllocateExternalBackingStore+1601
8: 00007FF6642D5B65 v8::internal::GCIdleTimeHandler::ShouldDoContextDisposalMarkCompact+1029
9: 00007FF6642D5FB5 v8::internal::Factory::AllocateRaw+37
10: 00007FF6642E9AF6 v8::internal::FactoryBase<v8::internal::Factory>::NewFixedArrayWithFiller+86
11: 00007FF6642E9E03 v8::internal::FactoryBase<v8::internal::Factory>::NewFixedArrayWithMap+35
12: 00007FF6640F07DC v8::internal::OrderedHashTable<v8::internal::OrderedHashSet,1>::Allocate+124
13: 00007FF6640F329A v8::internal::OrderedHashTable<v8::internal::OrderedHashSet,1>::Rehash+58
14: 00007FF6640F1D3A v8::internal::OrderedHashTable<v8::internal::OrderedHashSet,1>::EnsureGrowable+90
15: 00007FF6640288D7 v8::internal::interpreter::JumpTableTargetOffsets::iterator::operator=+123479
16: 00007FF6644BB97D v8::internal::SetupIsolateDelegate::SetupHeap+465325
17: 00007FF6644A449D v8::internal::SetupIsolateDelegate::SetupHeap+369869
18: 000000E4C77AA3F5
解决办法
``
“build:prod”: "vue-cli-service build ",
// 修改为
“build:prod”: “node --max_old_space_size=4096 node_modules/@vue/cli-service/bin/vue-cli-service.js build --mode production”,
``
nginx配置
server {
listen 9528;
server_name localhost;
#charset koi8-r;
#access_log logs/host.access.log main;
root D:/demo_pro_vue/dist/;
location / {
try_files $uri $uri/ /index.html;
}
location /abc {
proxy_pass http://192.168.51.150:8082/;
}
location /def {
proxy_pass http://192.168.51.150:8282/;
}
#error_page 404 /404.html;
# redirect server error pages to the static page /50x.html
#
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root D:/demo_pro_vue/html/;
}
}
nginx location 路径匹配问题
location /abc
proxy_pass http://192.168.51.150:8082/
location 路径前带着/ 后面不带 模糊匹配 /abc 可以匹配到 /abcdfds/
前后都带着/ /abc 可以只能匹配到 /abc/
proxy_pass 后面不带 / 则不会将匹配到的location 进行替换
proxy_pass 后面带 / 则会将匹配到的location 进行替换 替换方式为 / 后面的内容 如果没有则替换为空
location /abc
proxy_pass http://192.168.51.150:8082/xxx
abc 会被替换成xxx