【问题标题】:Use Semantic UI with Lerna and yarn workspaces将语义 UI 与 Lerna 和 yarn 工作区一起使用
【发布时间】:2019-05-12 18:22:48
【问题描述】:

语义 UI(和 Fomantic UI)安装程序(众所周知?)不支持 yarn,因为它的交互式安装后脚本。即使在semantic.json 中使用"autoInstall": true,yarn 仍然会在第一次安装时中断。

这使得在使用工作区时,很难将主题语义 UI 安装保留在 Lerna monorepo 中自己的包中。即使 --ignore-scripts 被添加到 Lerna 的 package.json 脚本中,它仍然会在进行更改时不时地自行运行标准的 yarn install,并被语义 UI 阻止。

有没有办法解决这个问题?

【问题讨论】:

    标签: semantic-ui yarnpkg lerna yarn-workspaces


    【解决方案1】:

    实际上,您可以使用 fomantic-ui 让 autoInstall 与纱线一起工作,我只是运行了这些命令,它就起作用了

    $ yarn add fomantic-ui --ignore-scripts
    $ yarn --cwd node_modules/fomantic-ui run install
    

    语义.json

    -  "autoInstall": false,
    +  "autoInstall": true,
    

    现在每次运行yarn install 都会“跳过”安装脚本。

    确保您使用的是最新版本的 FUI

    在 FUI repo https://github.com/fomantic/Fomantic-UI/issues/386 上也有一个关于这个问题的完整问题

    【讨论】:

    • 虽然 autoInstall + ignore-scripts 可以让你在一个独立的项目中使用 yarn,但是当你有 Lerna/workspaces 来做自动纱线的事情时,这还不够。就像,我可以做lerna bootstrap --ignore-scripts 但随后的lerna add 仍然会打破这个。我认为 SUI/FUI 回购问题有点太快了,无法接受这个“解决方案”。 :-)
    【解决方案2】:

    一种方法是编辑packages/semantic-ui/package.json,从dependencies 中删除"semantic-ui",然后添加脚本"install": "node ./install.js"。然后创建一个生成npm install semantic-ui --no-save 的脚本,仅当在环境中检测到纱线时(以防止无限安装循环;检查process.env.npm_config_user_agent)。

    这是一种复杂且容易出错的方式,但是如果存在 semantic.json 和 "autoInstall": true,它将自动安装 Semantic UI 并运行 gulp 作业,从而使自定义主题可用于 @monorepo/semantic-ui/dist/semantic.min.css 的其他包。

    【讨论】:

      猜你喜欢
      • 2019-02-10
      • 1970-01-01
      • 2019-01-01
      • 2016-08-17
      • 1970-01-01
      • 1970-01-01
      • 2022-09-27
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多