V2EX = way to explore
V2EX 是一个关于分享和探索的地方
Sign Up Now
For Existing Member  Sign In
GiantHard

拒绝重复劳动,使用 nx 自动为项目添加 target

  •  
  •   GiantHard ·
    ZeekoZhu · Sep 24, 2022 · 1586 views
    This topic created in 1312 days ago, the information mentioned may be changed or developed.

    TL;DR

    nx 提供的 Project Inference 功能可以自动推断出项目需要的 build target ,只需要一次配置,所有项目都可以自动获得相关的 build target ,再也不用手动去复制粘贴 npm scripts 了。

    下面是一些在 nx 官网中没有提到的,需要注意的地方:

    • registerProjectTargets 必须是一个同步函数
    • registerProjectTargets 的参数是一个相对于 nx workspace 根目录的相对路径,可以通过 workspaceRoot 变量来得到绝对路径

    原文地址

    P.S. nx 相关的中文内容也太少了,网上能够搜到的基本上都是官方文档的翻译和简单介绍,希望我的实践记录能够帮到 nx 的中文用户

    No Comments Yet
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   946 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 29ms · UTC 20:52 · PVG 04:52 · LAX 13:52 · JFK 16:52
    ♥ Do have faith in what you're doing.