ng-packagr

Include json file in ng-packagr build

别来无恙 提交于 2021-02-18 18:09:45
问题 I want to import json file into my Angular 5 app and then build a lib. I can do the first part by including this code declare module "*.json" { const value: any; export default value; } to typings.d.ts , but when I try to build it it fails with error Cannot find module '../../assets/locale-en.json'. Any way to fix it? 回答1: In the end I just wrote script to convert json file to ts file and added it to script command for packagr build in package.json . package.json scripts: { "packagr": "node .

How do I use my tsconfig file with ng-packagr?

限于喜欢 提交于 2021-02-10 16:55:30
问题 I'm packaging an Angular 5 library with ng-packagr and I need to use my existing tsconfig.json. I've read the docs here https://github.com/ng-packagr/ng-packagr/blob/master/docs/override-tsconfig.md and it says I need to write a script (I was expecting an option in the config) and pass through the filepath to my tsconfig file. I don't understand where I write this code? I guess this needs to be an NPM script? The documentation and example seems to be very minimal. Help with this would be

Embed json in ng-packagr

此生再无相见时 提交于 2021-02-08 15:10:37
问题 In an angular cli project, I managed to embed json like this add to typings.d.ts declare module "*.json" { const value: any; export default value; } import .json import * as data from '../assets/data.json'; But if I want to compile this into an Angular 5 module with ng-packagr, I get the following error: Error at .../.ng_pkg_build/my-module/ts/src/app/my-module.module. ts:28:33: Cannot find module '../assets/data.json'. Did anyone encountered this issue and knows how to solve it? 回答1: Ng

Embed json in ng-packagr

柔情痞子 提交于 2021-02-08 15:10:26
问题 In an angular cli project, I managed to embed json like this add to typings.d.ts declare module "*.json" { const value: any; export default value; } import .json import * as data from '../assets/data.json'; But if I want to compile this into an Angular 5 module with ng-packagr, I get the following error: Error at .../.ng_pkg_build/my-module/ts/src/app/my-module.module. ts:28:33: Cannot find module '../assets/data.json'. Did anyone encountered this issue and knows how to solve it? 回答1: Ng

How to use secondary endpoints to create API for Angular library

送分小仙女□ 提交于 2021-01-29 14:10:34
问题 Scenario: I created a custom UI library using ng-packagr , exported custom components and some model classes. Problem: In main project, import statement works fine for exported components but it doesn't work for exported classes and webpack fails to compile giving error: module not found error can't resolve my-custom-library/models Library project code: Model class: src/app/modules/my-custom-module/models/my-model.ts export class MyModel { constructor() { // default values for props here } //

Use Postcss in Custom Angular Library

China☆狼群 提交于 2020-05-10 14:25:10
问题 I used postcss, postcss-css-modules and posthtml-css-modules to implement CSS Modules in a Angular Application. I also used @angular-builders/custom-webpack to achieved this. Now, I want to do the same with my Custom Angular Library. However, I cannot use @angular-builders/custom-webpack because the Angular Libraries are build using ng-packagr. So, @angular-builders/custom-webpack is not available to use: https://github.com/just-jeb/angular-builders/issues/356 On the other hand, ng-packagr

Include assets when building library using ng-packagr

隐身守侯 提交于 2019-12-21 07:01:19
问题 Could anyone give a hint where to start to include images and css files into Angular library using ng-packagr? 回答1: There's an official issue for that question here. It's actually quite simple to include images and the like to your library: You can just copy them to the dist folder manually after ng-packagr has done its thing. However, it's more difficult to automate the extraction of those files in projects that'll use your library. In the issue referenced above BenjaminDobler suggests to