Skip to content

Commit 4ea3966

Browse files
committed
adding to readme
1 parent c896836 commit 4ea3966

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

packages/addon-dev/README.md

+20
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,26 @@ For a guide on porting a V1 addon to V2, see https://github.com/embroider-build/
2222

2323
A rollup plugin to expose a folder of assets. `path` is a required to define which folder to expose. `options.include` is a glob pattern passed to `walkSync.include` to pick files. `options.exlude` is a glob pattern passed to `walkSync.ignore` to exclude files. `options.namespace` is the namespace to expose files, defaults to the package name + the path that you provided e.g. if you call `addon.publicAssets('public')` in a v2 addon named `super-addon` then your namespace will default to `super-addon/public`.
2424

25+
### addon.keepAssets(patterns: string[], exports?: 'default' | '*')
26+
27+
A rollup plugin to preserve imports of non-Javascript assets unchanged in your published package. For example, the v2-addon-blueprint uses:
28+
29+
```js
30+
addon.keepAssets(['**/*.css'])
31+
```
32+
33+
so that the line `import "./my.css"` in your addon will be preserved and the corresponding CSS file will get included at the right path.
34+
35+
`keepAssets` is intended to compose correctly with other plugins that synthesize CSS imports, like `glimmer-scoped-css`. It will capture their output and produce real CSS files in your published package.
36+
37+
The `exports` option defaults to `undefined` which means the assets are used for side-effect only and don't export any values. This is the supported way to use CSS in v2 addons. But you can also preserve assets that present themselves as having default exports with the value `"default"` or arbitrary named exports with the value `"*"`. For example:
38+
39+
```js
40+
addon.keepAssets(["**/*.png"], "default")
41+
```
42+
43+
lets you say `import imageURL from './my-image.png'`. Not that this pattern is **not** automatically supported in V2 addons and you would need to tell apps that consume your addon to handle it in a custom way.
44+
2545
## addon-dev command
2646

2747
The `addon-dev` command helps with common tasks in v2 addons.

0 commit comments

Comments
 (0)