Skip to content

Commit 93b314d

Browse files
nivekcodeatscott
authored andcommitted
docs: including additional assets into libraries (angular#44076)
PR Close angular#44076
1 parent 28ef5af commit 93b314d

File tree

2 files changed

+27
-0
lines changed

2 files changed

+27
-0
lines changed

aio/content/guide/angular-package-format.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,10 @@ Tooling that is aware of these keys may preferentially select a desirable code f
107107

108108
* `"default"` selects flattened ES2020 code for all other consumers.
109109

110+
Libraries may want to expose additional static files which are not captured by the exports of the JavaScript-based entry-points such as Sass mixins or pre-compiled CSS.
111+
112+
For more information, see [Managing assets in a library](/guide/creating-libraries#managing-assets-in-a-library).
113+
110114
### Legacy resolution keys
111115

112116
In addition to `"exports"`, the top-level `package.json` also defines legacy module resolution keys for resolvers that don't support `"exports"`. For `@angular/core` these are:

aio/content/guide/creating-libraries.md

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -152,6 +152,29 @@ npm publish
152152
In your Angular library, the distributable can include additional assets like theming files, Sass mixins, or documentation (like a changelog).
153153
For more information [copy assets into your library as part of the build](https://github.com/ng-packagr/ng-packagr/blob/master/docs/copy-assets.md) and [embed assets in component styles](https://github.com/ng-packagr/ng-packagr/blob/master/docs/embed-assets-css.md).
154154

155+
<div class="alert is-important">
156+
157+
When including additional assets like Sass mixins or pre-compiled CSS. You need to add these manually to the conditional ["exports"](guide/angular-package-format/#exports) in the `package.json` of the primary entrypoint.
158+
159+
`ng-packagr` will merge handwritten `"exports"` with the auto-generated ones, allowing for library authors to configure additional export subpaths, or custom conditions.
160+
161+
<code-example language="json">
162+
"exports": {
163+
".": {
164+
"sass": "./_index.scss",
165+
},
166+
"./theming": {
167+
"sass": "./_theming.scss"
168+
},
169+
"./prebuilt-themes/indigo-pink.css": {
170+
"style": "./prebuilt-themes/indigo-pink.css"
171+
}
172+
}
173+
</code-example>
174+
175+
The above is an extract from the [@angular/material](https://unpkg.com/browse/@angular/material/package.json) distributable.
176+
</div>
177+
155178
## Peer dependencies
156179
Angular libraries should list any `@angular/*` dependencies the library depends on as peer dependencies.
157180
This ensures that when modules ask for Angular, they all get the exact same module.

0 commit comments

Comments
 (0)