Solvedangular cli Library support for assets, styles or scripts.

Bug Report or Feature Request (mark with an x)

- [ ] bug report -> please search issues before submitting
- [X] feature request


- [X] devkit
- [ ] schematics


Node: 8.11.3
NPM: 5.6.0
OS: Windows 10 Pro
Angular CLI 6.0.7
Ng-packagr: 3.0.1
Devkit Core: 0.6.7

Repro steps

Attempt to provide assets, styles or scripts to a library project and you will encounter a schema validation error due to the these properties not being supported currently for library projectTypes.

The log given by the failure

Schema validation failed with the following errors:
  Data path "" should NOT have additional properties(assets).

Desired functionality

I would like to be able to provide assets, styles and scripts in the same way that they can be provided to an application projectType.

Mention any other details that might be useful

I believe that ultimately this relates to ng-packagr's schema for library packages. In searching for previously reported requests on this, I did find a 'nice to have' request that had been opened in the devkit repo, which now points to this repo (angular/devkit#680).

13 Answers

✔️Accepted Answer

I dislike these solutions involving a post build step.
None of this can be applied when using ng build --watch=true
Developer workflow with HMR goodness is lost.
We need a built-in way to copy scss to dist without the post build hack.

Other Answers:

@bniedermeyer thx, I see, that sucks a bit but that's better than nothing ;)
I hope this will be supported by angular-cli soon :)

This would be great to see. If you need this to work now though, there is an existing workaround. Essentially you need to add a post-build script to your project or in something like Gulp to manually copy your assets to dist/.

See ng-packagr/ng-packagr#839 (comment) for an example of someone doing something similar to bundle their scss files.

More Issues: