2

我创建了一个使用 typescript 和 redux 的自定义反应库。

我做的第一件事是创建一个名为 react-tree 的项目,这是用 react 开发的,我使用了 typescript 和 redux。另外,我创建了一个样式文件夹,我在图标文件夹中添加了 fontello,如图所示。

然后我创建了一个项目,我称之为 react-tree-library 来发布并且两者都可以完美运行。

我遇到的问题是在库(react-tree-librart)中没有导出样式。

当我npm run build在 react-tree 中执行此操作时,这会生成一个构建文件夹,并且 /build/static/media 内部是 fontello 字体、图像。

来自反应树的脚本

“构建”:“fontello-cli 安装 --config ./src/styles/components/icons/config.json --css ./src/styles/components/icons/css --font ./src/styles/components/图标/字体 && react-scripts build",

但是,当我npm run build在 react-tree-library 中进行操作时,会生成两个文件夹:build 文件夹和 dist 文件夹。

来自 react-tree-library 的脚本

“脚本”:{“fontello”:“fontello-cli安装--config./src/tree/styles/components/icons/config.json--css./src/tree/styles/components/icons/css--字体 ./src/tree/styles/components/icons/font && react-scripts build", "build": "npm run fontello && tsc" },

这是因为我在打电话react-scripts buildtsc我知道那是错误的。

但这是我的问题,如何在 dist 文件夹中生成样式以发布带有样式的库?

这是我的 tsconfig.json

{
  "compilerOptions": {
      "target": "es5",
      "module": "commonjs",
      "declaration": true,
      "declarationMap": true,
      "sourceMap": true,
      "jsx": "react",
      "strict": true,
      "outDir": "./dist",
      "esModuleInterop": true,
  },
  "include": ["src"]
}

这是我的项目的图片:

在此处输入图像描述

4

0 回答 0