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

@kite-tech/webpack

v2.1.1-alpha.1

Published

Webpack build configs for Kite

Downloads

85

Readme

Kite webpack build processes

A configurable webpack process that can run apps locally using the webpack dev server and produce build versions of the app.

This is designed to be shared by a number of Kite apps which use Angular and follow a simliar structure.

The systems surrounding the webpack config are based on the react-dev-utils, https://www.npmjs.com/package/react-dev-utils This aims to log errors and warnings in a helpful way and reduce the noise from webpack.

Requirements

  • Node v8+
  • Npm v5+

Setup

  • Install via npm
npm i --save-dev @kite-tech/webpack
  • Add the build processes to the package.json
{
    "scripts": {
    "build:dev": "kite-tech-webpack:dev --partner-name=irista --project-config-location=kite-webpack-config.js",
    "build:dist": "concurrently \"npm run build:dist:irista\" \"npm run build:dist:canon\" \"npm run build:dist:kite\"",
    "build:dist:irista": "kite-tech-webpack:dist --partner-name=irista --project-config-location=kite-webpack-config.js",
    "build:dist:canon": "kite-tech-webpack:dist --partner-name=canon --project-config-location=kite-webpack-config.js",
    "build:dist:kite": "kite-tech-webpack:dist --partner-name=kite --project-config-location=kite-webpack-config.js",
    "start": "npm run build:dev"
    }
}
  • Run the script you want
npm run build:dev

Passing arguments

Certain arguments can be passed to the scripts to configure them in the way you want.

You are able to pass the normal webpack CLI arguments and they should be applied to the dev server. E.g:

npm run build:dev -- --quiet=false

In addition to that there are a couple of other options that can be set.

npm run build:dev -- --disable-source-maps
npm run build:dev -- --verbose
npm run build:dev -- --disable-base64-images
  • disable-source-maps will remove source maps completely.
  • verbose will include more logging in the terminal.
  • disable-base64-images will remove the loader that inlines smaller images as base64

You can also set some of these via environment vars. E.g you can run something like PARTNER_NAME=canon npm run build:dev to run the canon version of an app.

Configuring the build system

By default the config will be setup with some default paths which will allow projects using the standard structure we use to skip this section. But projects with different structures can configure their paths.

A project can pass paths to the build processes to define where certain elements are.

You should include the path to this file in the build.

node ./node_modules/@kite-tech/webpack/build/build.dev.js --partner-name=irista project-config-location=custom-project-config.js

This file should be in the below format where each path includes the full path to the app.

    module.exports = {
        paths?: {
            dir?: {
                appBuild?: string;
                appPublic?: string;
                appSrc?: string;
                appStyles?: string;
                appNodeModules?: string;
                appPreAngularStyles?: string;
                appKiteComponentsModule?: string;
            };
            files?: {
                appHtml?: string;
                appIndexJs?: string;
                appPackageJson?: string;
                appPreAngularScss?: string;
            };
            urls?: {
                publicUrl?: string;
                servedPath?: string;
            };
        };
        webpackOutput?: {
            path?: string;
            filename?: string;
            chunkFilename?: string;
        };
        webpackPlugins?: {
            development?: webpack.Plugin[];
            production?: webpack.Plugin[];
        };
    };

To get the full app path you can use the function at like so:

const appPathGenerator =
    require('@kite-tech/webpack/utils/app-path-generator');
const nodeModulesFullPath = appPathGenerator('node_modules');

The other part is the additional plugins that will be applied by Webpack.

Ahead of Time Compilation (AOT)

To have the application build in AOT mode you need to enable and set these variables:

process.env.NODE_ENV = 'production';
process.env.AOT_READY = 'true';

This will compile the typescript in the app using the @ngtools/webpack package.

Custom HTML for partners

Partner html can be included by adding code to files in the /assets/partner/{partnerName}/ directory of an app. These files are the index-head.html and the index-footer.html.

The index-head.html is dropped into the index.html where the <%= htmlWebpackPlugin.options.partnerHeadData %> line is.

The index-footer.html is dropped into the index.html where the <%= htmlWebpackPlugin.options.partnerFooterData %> line is.