How export styles to npm typescript library?

304 Views Asked by At

I've created a custom react library that use typescript and redux.

First thing I did was create a project called react-tree, this is developed with react and I have used typescript and redux. Also, I have created a styles folder where I have added fontello in the icons folder, as you can see on picture.

Then I have created a project, which I have called react-tree-library to publish and both work perfectly.

The problem I have is that in the library (react-tree-librart) the styles are not exported.

When I do npm run build in react-tree, this generate a build folder and inside /build/static/media are fontello fonts, images.

script from react-tree

"build": "fontello-cli install --config ./src/styles/components/icons/config.json --css ./src/styles/components/icons/css --font ./src/styles/components/icons/font && react-scripts build",

However, when I do npm run build in react-tree-library, this generate two folders: build folder and dist folder.

script from react-tree-library

"scripts": { "fontello": "fontello-cli install --config ./src/tree/styles/components/icons/config.json --css ./src/tree/styles/components/icons/css --font ./src/tree/styles/components/icons/font && react-scripts build", "build": "npm run fontello && tsc" },

This is because I'm calling react-scripts build and tsc, I know that is wrong.

But that's my problem, How can I make the styles be generated in the dist folder to publish the library with the styles?

This.is my tsconfig.json

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

And here is a picture of my project:

enter image description here

0

There are 0 best solutions below