Providing scss and ttf files in angular library

Asked

Viewed 37 times

0

I am creating an Angular library with NPM and would like to have a css folder and custom fonts available in the final build, so it is possible for me to just import the scss files into the applications that will install this library directly into their scss files.

Structure of lib:

src/
--lib/
----styles/
------variables.scss
------custom.scss
----components/
--public_api.ts
--test.ts
package.json

Import would be something like?

@import '~@minhalib/styles/variables.scss'

1 answer

0


Done

I don’t know if it’s the best way, but

Put this code in scripts in the package.json file, then use npm run build-mylib that it will build and play on a tgz

    "build-mylib": "ng build mylib && npm run cp-styles && npm run cp-assets && cd dist/mylib/ && npm pack",
    "cp-styles": "cpx \"./projects/mylib/src/lib/styles/**/*\" \"./dist/mylib/styles\"",
    "cp-assets": "cpx \"./projects/mylib/src/lib/assets/**/*\" \"./dist/mylib/assets\""

Browser other questions tagged

You are not signed in. Login or sign up in order to post.