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

d2-app-base

v1.0.0-rc.0

Published

An NPM module that provides a common setup for DHIS 2 web apps

Downloads

2

Readme

D2 App Base

Shared configuration package for DHIS2 apps using Webpack & Babel.

Getting started

Start by removing Webpack, HtmlWebpackPlugin and D2 Manifest. Since D2 App Base includes these dependencies, it's best not to include them in your app as well. That way you don't risk ending up with multiple versions of the packages in your node_modules.

yarn remove webpack html-webpack-plugin d2-manifest eslint eslint-config-dhis2

Or:

npm remove --save webpack html-webpack-plugin d2-manifest

Then install this package:

yarn add d2-app-base or npm install --save d2-app-base

After all dependencies have been installed, the post-install script will create the following NPM scripts:

  • start: Starts webpack-dev-server on localhost port 8081 (by default)
  • build: Packages the app into the build/ folder. This also runs prebuild and postbuild which will clean up any previous builds, validate and lint your code, and copy additional files.
  • deploy: Deploy a new version of the app to Sonatype. This runs the build script first.

At this point, if you're lucky everything will just work. Start the dev server with yarn start (or npm start), bump the version number with yarn version, and deploy new versions of your app with yarn deploy.

More likely you'll have to make some small adjustments to the webpack config (webpack.config.js), the html template (index.html) or the npm scripts (package.json). For example you may have to adjust the postbuild script in package.json to ensure that all the necessary files are copied to the build/ folder. Note: You shouldn't copy index.html since this will be generated by HtmlWebpackPlugin.

You may also have to fix a ton of eslint errors. Please do fix them rather than disabling the linting, but feel free to suggest changes to the eslint config if certain rules are causing problems. You may also override the rules in each repo/folder by changing .eslintrc

Webpack config

By default, webpack will use ./src/index.js as the entry point of your app, and the name of the output bundle will be [name]-[hash].js, where [name] will be replaced with the name of your entry point (defaults to "main") and [hash] will be replaced with a unique hash. Since the filename can't be known ahead of time, the HTML Webpack plugin is used to generate an index.html that loads the correct file(s).

The default webpack config simply calls makeWebpackConfig() which is defined in makeWebpackConfig.js. If you need to make changes to the webpack config, you can simply alter the object returned by this function. For example you can generate two output bundles by replacing the entry member:

const makeWebpackConfig = require('d2-app-base/makeWebpackConfig');

const webpackConfig = makeWebpackConfig(__dirname);

webpackConfig.entry = {
    'app': './src/app.js',
    'map': './src/map.js'
};

module.exports = webpackConfig;

Dependencies

This package includes certain dependencies on behalf of your app. If your app includes different versions of these dependencies you may end up with multiple versions in your node_modules folder. This can lead to weird bugs and unpredictable behavior.

Therefore, it's recommended that you remove the following dependencies from your app:

  • webpack
  • html-webpack-plugin
  • d2-manifest
  • eslint
  • eslint-config-dhis2