Yocto - NodeJS 缩小资产

Yocto - NodeJS minify assets

我想在节点 js 上缩小项目 运行ning 的资产。我不想直接在目标上缩小,因为我们使用的 ARM 处理器没有足够的能力在启动时的合理时间内缩小所有资产。相反,我想在构建主机 (Yocto) 上启动缩小过程。我在网上搜索了有关此过程的任何帮助,但我没有。

理想情况下,我想在 Yocto 的 do_install 任务的构建机器的 js 文件中使用 node-minify 之类的东西。

我首先在 (meta-nodejs/issues/62) 寻求帮助,但没有得到帮助。因此,我现在正在这里尝试,因为我们很匆忙,我真的不知道如何实现这一目标。

这是基本食谱和我的问题:

SRC_URI = "svn://URL_TO_THE_TARGET_PROJECT \
    file://host-minify-asset-script.js"

DEPENDS = "nodejs-native "
RDEPENDS_${PN} = "nodejs "

inherit npm npm-install

do_install() {

    # This build/install dependency for target ?
    oe_runnpm install
    oe_runnpm prune --production

    # Is it the proper way to install node-minify on the host like this ?
    oe_runnpm_native install https://github.com/srod/node-minify/tarball/2.0.2

    # Now, how can I run natively my script (host-minify-asset-script.js) 
    # to minify the assets present in the work folder of the recipe ?
}    

此致,

您可以使用 uglify 来缩小您的节点源。

npm install -g uglify # install uglify

rm -rf ./minified # remove existing minified directory if it exists

# minify each .js file in the current directory and place the output in ./minified
find . -name "*.js" | xargs -I % sh -c 'mkdir -p ./minified/$(dirname %); uglify -s % -o ./minified/%'