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

@webacad/angular-tools

v2.0.2

Published

Tool set for angular applications

Downloads

26

Readme

NPM version Build Status

WebACAD/AngularTools

Ready to use tool set for angular applications

Includes

  • Express server
  • Handlebars template engine for server
  • HMR (hot module replacement)
  • Webpack
    • Development/production modes
    • Multiple entries
    • Hashed chunks
    • @ngtools/webpack + AngularCompilerPlugin
    • file-loader for fonts
    • webpack.DefinePlugin
  • Sass + PostCSS

Installation

$ npm install --save rxjs@^5.5.0
$ npm install --save @angular/core@^5.0
$ npm install --save @angularclass/hmr
$ npm install --save @webacad/angular-tools

or with yarn

$ yarn add rxjs@^5.5.0
$ yarn add @angular/core^5.0
$ yarn add @angularclass/hmr
$ yarn add @webacad/angular-tools

About documentation

All examples are written in typescript.

Configure webpack

webpack.config.ts:

import {EnvironmentType} from '@webacad/angular-tools';
import {webpackConfigFactory} from '@webacad/angular-tools/webpack';
import * as webpack from 'webpack';

const environment: EnvironmentType = 'development';    // possible values are "development" or "production"

function createWebpackConfig(): webpack.Configuration
{
    return webpackConfigFactory(environment, {
        root: __dirname,
        distDir: '/path/to/public/dist/directory',
        publicPath: '/url/path',
        hmr: true,
        sourceMaps: true,
        angular: {
            entryModule: './app.module#AppModule',
        },
        postcss: {
            config: '/path/to/postcss/config.js',
        },
        webpack: {
            analyze: true,
            fonts: {
                outputPath: 'relative/path/to/publicPath',
                publicPath: '/url/path',
            },
            plugins: {
                define: {
                    'process.env': {
                        'NODE_ENV': `'${environment}'`,
                    },
                },
            },
            entry: {
                polyfills: './app/polyfills.ts',
                app: './app/main.ts',
                styles: './styles/index.scss',
            },
        },
    });
}

export default createWebpackConfig;

Configure express server

server/server.ts:

import {EnvironmentType} from '@webacad/angular-tools';
import {createServer} from '@webacad/angular-tools/expressjs';
import createWebpackConfig from '../webpack.config';
import * as path from 'path';

const environment: EnvironmentType = 'development';

createServer(environment, createWebpackConfig(), {
    index: path.join(__dirname, 'views', 'index.handlebars'),
    port: 8080,
    hmr: true,
    staticPaths: {
        '/public/images': '/path/to/public/images',    // using express.static
    },
    parameters: {    // parameters passed to handlebar templates

    },
});

server/views/index.handlebars:

<!DOCTYPE html>
<html>
    <head>
        <meta charset="UTF-8">
        <base href="/">

        {{#if production}}
            <link rel="stylesheet" href="{{assets 'styles/css'}}">
        {{/if}}
    </head>
    <body>
        <my-app>Loading...</my-app>

        <script src="{{asset 'manifest/js'}}"></script>

        {{#if hmr}}
            <script src="{{asset 'hmr/js'}}"></script>
        {{/if}}

        {{#if development}}
            <script src="{{asset 'styles/js'}}"></script>
        {{/if}}

        <script src="{{asset 'polyfills/js'}}"></script>
        <script src="{{asset 'app/js'}}"></script>
    </body>
</html>

Build-in template variables

  • production: True for production environment
  • development: True for development environment
  • hmr: True if hot module replacement is allowed

Assets

Styles/css:

Automatically generated css file which should be used only in production environment.

Manifest/js:

Automatically generated manifest file.

Hmr/js:

Automatically generated hmr configuration (only if hmr is allowed).

Styles/js:

Automatically generated js file with styles which should be used only in development environment.

Polyfills/js:

Your polyfills.ts entry file.

App/js:

Your app.ts entry file.

Main.ts file

import {platformBrowserDynamic} from '@angular/platform-browser-dynamic';
import {enableProdMode} from '@angular/core';
import {hmrBootstrap} from '@webacad/angular-tools/hmr';

import {AppModule} from './app.module';

const bootstrap = () => platformBrowserDynamic().bootstrapModule(AppModule);

if (process.env.NODE_ENV === 'production') {
    enableProdMode();
    bootstrap();

} else {
    Error['stackTraceLimit'] = Infinity;
    require('zone.js/dist/long-stack-trace-zone');

    if (module['hot']) {
        hmrBootstrap(module, bootstrap);
    } else {
        bootstrap();
    }
}

Update scripts in package.json

package.json:

{
    "scripts": {
        "build": "webpack",
        "start": "ts-node server/server.ts"
    }
}