I'm using Angular 8 and I have a separate application with its own CSS styles and assets. I want to embed the library component inside the main application like
<lib-landing-page-preview></landing-page-preview>
The directory structure is
The library assets are inside the /projects/landing-page-preview/src/assets
where the style.scss
is the main CSS file inside the scss
directory.
The root angular.json
file has been updated
{
"$schema": "./node_modules/@angular/cli/lib/config/schema.json",
"version": 1,
"newProjectRoot": "projects",
"projects": {
... // main application project
"landing-page-preview": {
"projectType": "library",
"root": "projects/landing-page-preview",
"sourceRoot": "projects/landing-page-preview/src",
"prefix": "lib",
"architect": {
"build": {
"builder": "@angular-devkit/build-ng-packagr:build",
"options": {
"tsConfig": "projects/landing-page-preview/tsconfig.lib.json",
"project": "projects/landing-page-preview/ng-package.json",
"assets": [
{
"glob": "*/*",
"input": "projects/landing-page-preview/src/assets",
"output": "src/assets"
}
]
}
},
"test": {
"builder": "@angular-devkit/build-angular:karma",
"options": {
"main": "projects/landing-page-preview/src/test.ts",
"tsConfig": "projects/landing-page-preview/tsconfig.spec.json",
"karmaConfig": "projects/landing-page-preview/karma.conf.js"
}
},
"lint": {
"builder": "@angular-devkit/build-angular:tslint",
"options": {
"tsConfig": [
"projects/landing-page-preview/tsconfig.lib.json",
"projects/landing-page-preview/tsconfig.spec.json"
],
"exclude": [
"**/node_modules/**"
]
}
}
}
}},
"defaultProject": "qcg-frontend"
}
While development, I'm the library is build using following command
ng build landing-page-preview --watch
and running the main application using
ng serve
But the assets files in the library directory does not seem to be working.
The ng build landing-page-preview --watch
command gives
Schema validation failed with the following errors:
Data path "" should NOT have additional properties(assets).