小编Hos*_*lah的帖子

如何从react-scripts构建脚本获取详细日志?

我升级到react-scriptsv5,但构建失败并显示一条无用的消息:

Creating an optimized production build...
Failed to compile.

Module not found: Error: Can't resolve '...' in '/project/src'
Run Code Online (Sandbox Code Playgroud)

src正如您所看到的,它仅告诉我目录(实际上是整个项目)存在问题。

如何增加该脚本的详细程度?

reactjs react-scripts

19
推荐指数
1
解决办法
4167
查看次数

如何将 next.js 图像组件与 HTML <picture> 元素一起使用?

Next.js 有一个Image组件,可以延迟加载图像,并srcset为给定的图像提供 a 。

然而,有时我们想为不同的设备提供不同的图像(艺术重定向)。

Mozilla表示我们应该使用<picture>element 来实现此目的,为不同的媒体查询提供不同的图像。

我找不到一篇文章(即使在 next.js 官方文档中)来告诉我们如何使用<Image>组件来做到这一点。

是否可以?如何一起使用 next.js<Image>组件和 HTML<picture>元素?

html image next.js

12
推荐指数
1
解决办法
1万
查看次数

是否可以在我的 shell 文件中使用 GitHub 机密?

这是我在 GitHub 存储库上的简单操作:

name: CI

on:
  push:
    branches: [ main ]

jobs:
  build:
    runs-on: ubuntu-latest
    steps:
      - name: Get /my_account/my_infra
        run: |
          sudo mkdir /my_account
          sudo chmod -R 777 /my_account
          cd /my_account
          git clone https://github.com/my_account/my_infra

      - name: Get /my_account/my_repo
        run: |
          cd /my_account
          git clone https://github.com/my_account/my_repo

      - name: Run my build script
        run: |
          cd /my_account/my_infra
          ./build.sh /my_account/my_repo
Run Code Online (Sandbox Code Playgroud)

由于 GitHub 不提供跨多个类似存储库重用操作的方法,因此我提出了创建一个基本存储库的想法,然后将该基本存储库与当前存储库一起下载,然后从该基本存储库运行自定义 shell 脚本,传递我当前的repo 作为参数。

这很完美。这样我就可以在许多类似的存储库中重复使用我的基础存储库。我可以重用近 500 行构建脚本,而不是为 50 个存储库重复自己(这意味着 25000 行 CI/CD 代码)。

但是,现在我需要访问一些资源(例如登录我的 docker hub 帐户)来拉取和推送内容。

是否可以在我的 中使用 GitHub …

shell github github-actions

10
推荐指数
2
解决办法
8839
查看次数

坚持在 GitHub Actions 中使用 PAT(个人访问令牌)

我有一个 GitHub 帐户。

我有一个私人组织。还有一些私人存储库。

我想在我的私人组织中为我的私人存储库定义一个操作。

private_org\private_rpo

我可以检查我的private_repo使用情况${{ github.token }}action/checkout@2

但是,我无法在该存储库的操作中查看我的其他存储库。

这是我的代码:

      - name: Get private_org/private_repo using actions/checkout@v2
        uses: actions/checkout@v2
        with:
          repository: private_org/private_repo
          token: ${{ github.token }}
          path: private_org/private_repo
          
      - name: Get private_org/private_repo_2 using actions/checkout@v2
        uses: actions/checkout@v2
        with:
          repository: private_org/private_repo_2
          token: ${{ github.pat }}
          path: private_org/private_repo_2 
Run Code Online (Sandbox Code Playgroud)

我在我的帐户(开发人员设置)中创建了一个 PAT,并patprivate_org/private_repo.

然而,action/checkout@2抱怨说:

运行 actions/checkout@v2
错误:需要输入但未提供:令牌

我应该如何解决这个问题?我应该在哪里定义我的pat秘密?如何在此私有存储库的操作中签出我的其他私有存储库?

github github-actions

8
推荐指数
1
解决办法
9760
查看次数

我可以将 GitHub Actions 符号链接到存储库内的目录吗?

我有一个存储库,并且有一个代码生成器,可以在某些目录中生成 GitHub Actions。

例如:

- repo_root
  - .github/workflows
    - site.yml <= this is a relative symlink to site's build.yml
    - blog.yml <= this is a relative symlink to blog's build.yml
  - site
    - .github/workflows/build.yml
  - blog
    - .github/workflows/build.yml
Run Code Online (Sandbox Code Playgroud)

我已经使用此命令创建了这些符号链接,我可以验证它们是否正确(通过cat或 通过ls -lah):

ln -s -f -r /repo/site/.github/workflows/build.yml /repo/.github/workflows/build.yml
Run Code Online (Sandbox Code Playgroud)

但是,它们在 GitHub 中不被识别为操作,并且会立即失败。

有可能吗?

github-actions

7
推荐指数
1
解决办法
1618
查看次数

如何在nginx中为多个网站创建反向代理

我有许多不同的技术在我的本地计算机上为 API 和站点提供服务。我希望能够通过人类可读的名称而不是端口来查看它们。

例如,我有:

  • localhost:8000 => 用户面板的 laravel api
  • localhost:8001 => 用于管理面板的 laravel api
  • localhost:3000 => 对用户面板做出反应客户端
  • localhost:3001 => 站点的 nextjs 客户端
  • 本地主机:3002 => 为管理面板反应客户端

这个清单还在继续。

当然,记住所有这些端口是不可能的。因此我想为他们设置一个反向代理:

  • api.user.example.local
  • api.admin.example.local
  • 示例.local
  • 用户.example.local
  • 管理员.example.local

我知道我必须将这些主机头添加到/etc/hosts文件中。我还阅读了如何将 nginx 配置为一个域的反向代理

我不知道如何为许多网站做到这一点。并且仅作为反向代理,不作为服务器。

reverse-proxy nginx

6
推荐指数
1
解决办法
3万
查看次数

如何强制 System.Text.Json.JsonElement.GetProperty 使用不区分大小写的方法搜索属性?

这是我的 JSON:

{
    firstName: 'Somebody',
    lastName: 'Else'
}
Run Code Online (Sandbox Code Playgroud)

我将其反序列化为JsonElement使用以下选项:

var options = new JsonSerializerOptions {
                    WriteIndented = true,
                    PropertyNameCaseInsensitive = true,
                    PropertyNamingPolicy = JsonNamingPolicy.CamelCase
                };
Run Code Online (Sandbox Code Playgroud)

但后来我想搜索属性,它变得区分大小写

element.GetProperty("FirstName") // this returns null
element.GetProperty("firstName") // this returns 'Somebody'
Run Code Online (Sandbox Code Playgroud)

如何强制GetProperty方法不区分大小写?

.net c# system.text.json

5
推荐指数
1
解决办法
2661
查看次数

Vite抱怨Material UI图标无法解析

我将我的项目从 CRA 迁移到了 Vite。

当我运行时,npm run dev我收到此错误:

The following dependencies are imported but could not be resolved:

  @mui/icons-material/Article (imported by /Blog/Admin/Exports.jsx)
  @mui/icons-material/Comment (imported by /Social/Admin/Comment/View.jsx)
  @mui/icons-material/TextSnippet (imported by /Contents/Admin/Page/List.jsx)
  @mui/icons-material/FindInPage (imported by /Contents/Admin/Page/List.jsx)
  @mui/icons-material/AccountTree (imported by /Taxonomy/Admin/Hierarchy/Manage.jsx)
  @mui/icons-material/LocalOffer (imported by /Taxonomy/Admin/Tag/Manage.jsx)
  @mui/icons-material/NoteAlt (imported by /Forms/Admin/Form/List.jsx)
  @mui/icons-material/EventNote (imported by /Logs/Admin/Exports.jsx)
  @mui/icons-material/Navigation (imported by /Navigation/Admin/Exports.jsx)
  @mui/icons-material/Abc (imported by /Contents/Admin/Exports.jsx)
  @mui/icons-material/Fingerprint (imported by /Entities/Admin/Exports.jsx)
  @mui/icons-material/Support (imported by /Ticketing/Admin/Exports.jsx)
  @mui/icons-material/Shuffle (imported by /Entities/Admin/EntityType/List.jsx)
  @mui/icons-material/Delete (imported by /Logs/Admin/List.jsx)
  @mui/icons-material/Search (imported by /Contents/Admin/Image/List.jsx)
  @mui/icons-material/Done …
Run Code Online (Sandbox Code Playgroud)

reactjs material-ui vite

5
推荐指数
1
解决办法
9337
查看次数

System.Text.Json 不会驼峰化动态属性的属性

我正在使用 ASP.NET Core 和System.Text.Json.

这是我的示例操作方法:

    [HttpGet]
    public object Person()
    {
        dynamic relatedItems = new ExpandoObject();
        relatedItems.LastName = "Last";
        var result = new 
        {
            FirstName = "First",
            RelatedItems = relatedItems
        };
        return result;
    }
Run Code Online (Sandbox Code Playgroud)

这是我得到的回应:

{
    firstName: "First",
    relatedItems: {
        LastName: "Last"
    }
}
Run Code Online (Sandbox Code Playgroud)

正如你所看到的,LastName它是动态属性的一个属性,没有被骆驼化。

我怎样才能让所有东西都装在骆驼箱里回来?

更新。这个答案不是我的答案。正如你所看到的,我已经拥有firstName正确骆驼化的财产。

c# json camelcasing asp.net-core system.text.json

3
推荐指数
1
解决办法
779
查看次数

是否可以从多个来源编译 tailwind.config.js ?

这是一个典型的tailwind.config.js文件:

module.exports = {
  content: [
    "./pages/**/*.{js,ts,jsx,tsx}",
    "./components/**/*.{js,ts,jsx,tsx}",
  ],
  theme: {
    extend: {},
  },
  plugins: [],
}
Run Code Online (Sandbox Code Playgroud)

由于我们正在创建一个基础架构,因此我们希望将此文件拆分为两个配置文件,并在 nextjs 构建之前重新加入/重新编译它们。

例如,我们希望tailwind.config.base.js它是集中的并包含:

  content: [
    "./pages/**/*.js",
    "./components/**/*.js",
    "./base/**/*.js",
    "./contents/**/*.js",
    "./modules/**/*.js"
    // Here we have a chance to centralize our directory structure
    // We can also prevent common mistakes
    // And we can ensure that all projects use js and not typescript
  ],
  plugins: [
    require('@tailwindcss/typography')
    // Here we have the chance to give all of our projects a …
Run Code Online (Sandbox Code Playgroud)

next.js tailwind-css

3
推荐指数
1
解决办法
1148
查看次数