npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

ngx-library-assets

v2.0.4

Published

Angular builders to include assets from libraries into applications

Downloads

1,005

Readme

ngx-library-assets

Angular builders to include assets from libraries into applications

Why use this

When changing files within a monorepo, it's best to keep affected projects to a minimum. Assets for libraries are not automatically copied when building the application that depend on them. A change to angular.json is mostly ruled as a change affecting every project in the monorepo. To reduce the need to alter angular.json every time a new library is needed for an application, and to avoid creating 'shared' libraries with assets, this package can be used. With this package, the libraries can keep their assets in their own source. Including assets from an existing library into an application is as easy as to update 1 file in that application, making it the only affected application.

How to use this

  1. Install using yarn or npm: yarn add -D ngx-library-assets
  2. In angular.json:
  • set the builder for the serve target to ngx-library-assets:dev-server
  • set the builder for the build target to ngx-library-assets:browser
  1. In your application, add an include.json file inside src/assets
{
  "$schema": "<relative path to node_modules>/ngx-library-assets/include-schema.json",
  "libs": [
    {
      "name": "<name of library>",
      "assetsRoot": "<boolean, optional, default = false>"
    }
  ]
}

name

The name of the Angular project to include assets from. This should be the name of the project as it is described in angular.json. If this name is not found in the workspace, a warning will appear in the console.

assetsRoot

When set to false or absent, all assets of that library will be placed in subfolders. This means, all files will be placed in /assets/<lib-project-name> keeping their folder structure.

When set to true, all assets of that library, apart from translations will be placed in the assets type root folder. This means, all files (except folder i18n) will be placed in /assets/images keeping their folder structure. But the content of folder i18n will still be placed in /assets/<lib-project-name>/i18n Be careful that the assets don't have the same names, they will overwrite each other.

Example

This repository contains an example workspace with a basic Angular application and 2 libraries. The shared library has option assetsRoot set to true. The my-lib library has option assetsRoot absent (default = false). The application's include.json also mentions an non-existing library, named example-non-existing-lib. To run the example project, cd into example and run npm install and then npm start.

Note: for versions prior to Angular 11, use v1.2.x