【问题标题】:CLI arguments of create-nx-workspacecreate-nx-workspace 的 CLI 参数
【发布时间】:2022-01-16 08:36:23
【问题描述】:

是否有一些关于create-nx-workspace 采用的参数的文档?我想构建一个复制和粘贴-able oneliner 来设置一个新的工作区,而无需询问任何交互式问题。到目前为止我有

npx create-nx-workspace@latest myworkspace --name myworkspace --preset web-components --appName myapp --cli angular

接下来它询问我要使用哪种默认样式表格式。而且我不知道如何将其指定为命令行参数。

【问题讨论】:

    标签: nrwl-nx


    【解决方案1】:

    目前没有在 create-nx-workspace 命令中定义样式的选项。如您所见,只有在确定 appName 承诺后才会提示查询样式:

    determineWorkspaceName(parsedArgs).then(name => {
        determinePreset(parsedArgs).then(preset => {
            return determineAppName(preset, parsedArgs).then(appName => {
                return determineStyle(preset).then(style => {
                    return determineCli(preset, parsedArgs).then(cli => {
                        const tmpDir = createSandbox(packageManager, cli);
                        createApp(tmpDir, cli, parsedArgs, name, preset, appName, style);
                        showCliWarning(preset, parsedArgs);
                        showNxWarning(name);
                        pointToTutorial(preset);
                    });
                });
            });
        });
    });
    

    determineStyle 的代码是here

    我已经准备 PR 将此功能添加到 create-nx-workspace 命令here

    【讨论】:

    • 哇,谢谢!您甚至为此添加了 PR 真是太酷了。
    • np。作为一种解决方法,您可以使用 create-nx-workspace --preset=empty 然后添加项目,例如Angular 使用 --style 选项已经在工作了
    • @kremerd PR 已经合并到 master 中,所以现在你可以等待新的发布版本能够使用 style 选项和你的其他选项以及 github.com/nrwl/nx/commit/…
    【解决方案2】:

    您可以选择用于设置应用程序样式的工具

    npx create-nx-workspace@latest myworkspace ... --style=css
    

    您可以使用以下选项之一

    • cssscssless 用于 Angular 项目
    • styl 适用于所有非 Angular,并且
    • styled-components@emotion/styledstyled-jsx 用于 React、Next.js 和 Gatsby。

    NX 的命令行选项

    您可以通过运行检查可用于创建 NX 工作区的命令行选项

    npx create-nx-workspace@latest --help
    

    以下是v13.4.5 版本的命令行选项:

    Option Description
    preset Tools to be used in the workspace (options: "apps", "empty", "core", "npm", "ts", "web-components", "angular", "angular-nest", "react", "react-express", "react-native", "next", "gatsby", "nest", "express")
    appName Name of the application
    cli CLI to be used (options: "nx", "angular")
    style style option (options: "css", "scss", "less" for Angular, "styl" for all non-Angular and "styled-components", "@emotion/styled", "styled-jsx" for React, Next.js and Gatsby)
    interactive enable interactive mode when using presets (boolean)
    packageManager package manager to use (npm, yarn, pnpm)
    nx-cloud yse Nx Cloud (boolean)

    【讨论】:

      猜你喜欢
      • 2019-12-12
      • 2021-09-28
      • 1970-01-01
      • 2021-08-12
      • 2021-10-04
      • 2020-08-28
      • 1970-01-01
      • 1970-01-01
      • 2017-08-24
      相关资源
      最近更新 更多