ali-hm / angular-tree-component

A simple yet powerful tree component for Angular (>=14)
https://angular2-tree.readme.io/docs
MIT License
28 stars 8 forks source link

the css file needs to be in the export section of the package.json #1

Closed jcompagner closed 1 year ago

jcompagner commented 1 year ago

I see you copy the "css" file to the root: /css/angular-tree-component.css

also ng-packages also has it as an asset (i guess you can remove that line?) https://github.com/ali-hm/angular-tree-component/blob/master/projects/angular-tree-component/ng-package.json#L4

Because that for some reason does include it, but doesn't include it in the package.json exports list it seems that you really need todo that in the package.json of the project:

https://github.com/ng-packagr/ng-packagr/blob/main/docs/copy-assets.md

so on this line: https://github.com/ali-hm/angular-tree-component/blob/master/projects/angular-tree-component/package.json#L47

we need:

"exports": { "./css/angular-tree-component.css": { "style": "./css/angular-tree-component.css" } }

so that it will compile because else if i include that lib and it try to import that css in my own:

@import '@ali-hm/angular-tree-component/css/angular-tree-component.css';

then i get:

Error: Package path ./css/angular-tree-component.css is not exported from package node_modules\@ali-hm\angular-tree-component (see exports field in \node_modules\@ali-hm\angular-tree-component\package.json)

ali-hm commented 1 year ago

I will consider your solution, but for the time being (as I mentioned in the README) you can use this line for the css: @import '../node_modules/@ali-hm/angular-tree-component/css/angular-tree-component.css'; make the relational path based on the file that you are importing the "angular-tree-component.css".

jcompagner commented 1 year ago

ah no, that is horrible for us, because that path can be quite specific, can be a parent of a parent node modules... if you ship stuff in the package there just needs to be a export entry in the package.json

ali-hm commented 1 year ago

It is resolved in v12.0.4. Now you can import css using this line: @import '@ali-hm/angular-tree-component/css/angular-tree-component.css';