EMBER_CLI_PROD_ASSETS 设置为 1 会在预编译资源时崩溃

供记录,也许对某些人有用。至少有一种方法可以让 ember cli 按预期使用随机 uid 工作,那就是确保在运行 rake assets:precompile 操作时,分配的随机 uid 在 /etc/passwd 下有一个条目。

类似这样:

if [ `id -u` -ge 10000 ]; then
  cat /etc/passwd | sed -e "s/^discourse:/builder:/" > /tmp/passwd
  echo "discourse:x:`id -u`:`id -g`:,,,:/home/discourse:/bin/bash" >> /tmp/passwd
  cat /tmp/passwd > /etc/passwd
  rm /tmp/passwd
fi

因此,命令 app/assets/javascripts/discourse run ember build -prod(来自 discourse/assets.rake at tests-passed · discourse/discourse · GitHub)将使其生效。

yarn run v1.22.17
$ /discourse/app/assets/javascripts/node_modules/.bin/ember build -prod
WARNING: Node v16.13.2 is not tested against Ember CLI on your platform. We recommend that you use the most-recent "Active LTS" version of Node.js. See https://git.io/v7S5n  for details.
DEPRECATION: The integration of jQuery into Ember has been deprecated and will be removed with Ember 4.0. You can either opt-out of using jQuery, or install the `@ember/jquery` addon to provide the jQuery integration. Please consult the deprecation guide for further details: https://emberjs.com/deprecations/v3.x#toc_jquery-apis
- Building
Environment: production
- Building
- building...
[WARN] (broccoli-terser-sourcemap) Minifying "assets/chunk.529.6ee9018498e97f872147.js" took: 24288ms (more than 20,000ms)
...

我还注意到这个操作相当耗费资源,仅仅预编译就消耗了近 2GB 的内存 :scream:

此致,
Ismael