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

@ngpack/ngpack

v0.0.1-alpha.1

Published

ngpack: the modular build system for Angular

Downloads

5

Readme

NgPack

Opinionated and modular webpack configuration generator for Angular 2 web applications

Installation

npm install @ngpack/ngpack @ngpack/base -D

# npm install @ngpack/typescript
# npm install @ngpack/tslint
# npm install @ngpack/postcss

Usage

Create your webpack configuration file (webpack.config.js) as you normally would, but instead of creating the config object directly, let ngpack create it for you, and make your own modifications where necessary. Here is how it might look (from examples/angular2-webpack-clone):

var config = module.exports = require('@ngpack/ngpack').ngpack
  // configure first
  .configure({
    // port: 9090,
    root: __dirname,
  })
  .add('@ngpack/base')
  .add('@ngpack/sass')
  .modify(overwritePostCSS)
  .add('@ngpack/typescript')
  .add('@ngpack/tslint')
  .add('@ngpack/istanbul')   // order matters: this has to be after typescript
  .add(extendWithAngular2TemplateLoader)
  .make();

function overwritePostCSS(config) {
  config.postcss = [
    require('autoprefixer')({
      browsers: ['last 4 version'],
    }),
  ];
}

function extendWithAngular2TemplateLoader(ngpack) {
  return {
    module:
    {
      loaders: [{
        loaders: ['angular2-template-loader', '@angularclass/hmr-loader'],
        test: /\.ts$/,
      }],
    },
  };
}

ngpack#configure

Allows configuring the port and the root of the project. That's all for now.

ngpack.add()

Adds an extension to the webpack configuration. The final config is generated by smart-merging various configs.

The method accepts one parameter, which can be any of the following:

  • a string: name of an ngpack extension module installed via NPM
  • a function: a function with the same signature as the provide method in an ngpack extension
  • an object: just a config object

ngpack.modify()

This differs from add, in that it allows you to modify the configuration object directly, without merging. It accepts a function with the following signature:

(config: Configuration, ngpack: NgPack): void;

The function receives the config object as its first argument, which it can freely modify. The second argument is the insntace of ngpack.

The return value of the function is ignored.

ngpack.util

Provides access to the following utility functions:

  • ngpack.util.isDev(): We're in development mode
  • ngpack.util.isProd(): We're in production mode
  • ngpack.util.isTest(): We're in testing mode
  • ngpack.util.isTestWatch(): We're in testing + watch mode
  • ngpack.util.root(...paths: string[]): generate an absolute path from the root of the project

Extensions

An ngpack extension is a simple NPM module that exports an object with a method called provide, which follows the following signature:

(ngpack?: NgPack): Configuration;

The function must return a configuration object, which will be merged using webpack-merge. There is just one parameter: the insntace of ngpack.

So, an extension module could be as simple as this:

module.exports = {
  provide: function(ngpack) {
    return {
      devtool: 'source-map'
    };
  }
};

The above might be pointless, but it's a valid and functional ngpack extension that will set the devtool option to source-map.

If you create a module, please add the ngpack-ext keyword to make it easier to find.