简体   繁体   中英

Assets not copied from project to dist folder in Angular 7 library

i've generated new library via Angular CLI v7

ng generate library library-name

After that, i've created folder assets in src folder. So my folder structure is

| - src
| - - lib
| - - - assets

My problem is, that after

ng build --project=library-name

are assets missing in my dist folder. All modules, components, styles etc. are exported in dist folder. But if i create another directory in this hierarchy, directory is not exported to dist at all.

How can i force assets to be exported in dist folder after build ?

Thanks

This is not currently supported by the CLI, you can read more in the GitHub issue here: https://github.com/angular/angular-cli/issues/11071#issuecomment-395096971

An easy workaround as suggested is to manually cp -r path/to/lib/assets list/path/to/lib the assets after you build the library. You could use a post build script in your package.json for this.

This has been fixed since approx. Jan 2020

src

tldr;

in ng-package.json or equiv. you can include what you want bundled:

{
  ...,
  "assets": [
    "./assets",
    "CHANGELOG.md",
    "./styles/**/*.theme.scss"
  ],
  ...
}

main project glob

You'll also want to be sure to include the glob in your angular.json that's importing the packaged lib.

condensed example:

"projects": { "hello-world": {
    "projectType": "application",
    "architect": { "build": { "options": {
      "assets": [
        ...,
        {
          "glob": "**/*",
          "input": "node_modules/your/library",
          "output": "./assets"
        }
      ]
} } } } }

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM