-
Notifications
You must be signed in to change notification settings - Fork 12k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Library support for assets, styles or scripts. #11317
Comments
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 See ng-packagr/ng-packagr#839 (comment) for an example of someone doing something similar to bundle their scss files. |
Thanks, @bniedermeyer - this is exactly what we're currently doing in the meantime ;) |
@bniedermeyer @mattezell sorry if I'm thick, but where should this "post build" script go exactly? I'm trying to simply copy a scss file (not even bundling it) to the dist directory without having to run many commands. Thanks :) |
@victornoel In my project I have a "post-build" script in the root No matter what you would want any npm script added to the At first we just scripted it in the CI pipeline itself but found using npm scripts to be a bit more flexible. |
@bniedermeyer thx, I see, that sucks a bit but that's better than nothing ;) |
@bniedermeyer but if you copy it manually how can you refference it from your code? |
@vytautas-pranskunas- you will want to copy the files (either manually or by scripting it as part of your build process) before you package and publish your library. Then the files will be available in An example of this pattern (although I don't think they use the same tools involved here) is found with Angular Material. They include assets in their library before it's published and then you import those assets as needed from node_modules (see here). I have not included anything in assets that is required in my code - normally I just include things like css files. You could probably import the files like you would import anything else if you needed to reference it in code. e.g. import {myAsset} from 'your-library/assets/myAsset' You will probably want to check the ng-packagr docs and make sure you don't need to do something like add a separate entry point though. Note also that this is in regard to assets for your library. Normal assets for your application can stay where they are. |
@bniedermeyer exactly but this i. Mport is not valid from my library. This is valid if you want to use asdets from outside but if i want to use 3thd party library in my source this will not going to work |
I dislike these solutions involving a post build step. |
Looks like this is also covered in #11071. I'd love to see this too, but the workaround is only irritating; it isn't horrible. |
Duplicate of #11071 |
This issue has been automatically locked due to inactivity. Read more about our automatic conversation locking policy. This action has been performed automatically by a bot. |
Bug Report or Feature Request (mark with an
x
)Area
Versions
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
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).
The text was updated successfully, but these errors were encountered: