create-nx-workspace 的 CLI 参数

CLI arguments of create-nx-workspace

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

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

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

目前没有在 create-nx-workspace 命令中定义样式的选项。可以看到只有确定appName promise后才会提示查询样式:

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);
                });
            });
        });
    });
});

确定样式的代码是here

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

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

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)