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

webpack-partial

v2.2.0

Published

Webpack partials.

Downloads

1,994

Readme

webpack-partial

Intelligently compose webpack configuration files.

build status coverage license version downloads

Usage

npm install --save webpack-partial

Making webpack configurations composable is tricky. So we provide several helpers to ease the composition process. Each helper is of the form (arg1, arg2, ..., webpackConfig). All functions are curried and the last argument is always a webpack configuration object allowing you to chain helpers together easily with compose (or flow).

Generally:

import compose from 'lodash/fp/compose';
import plugin from 'webpack-partial/plugin';
import StatsWebpackPlugin from 'stats-webpack-plugin';
import ExtractTextWebpackPlugin from 'extract-text-webpack-plugin';

const buildConfig = compose(
  plugin(new StatsWebpackPlugin()),
  plugin(new ExtractTextWebpackPlugin())
);

const config = buildConfig({/* webpack config here */});

But you can also use them individually if you need to:

import plugin from 'webpack-partial/plugin';
import StatsWebpackPlugin from 'stats-webpack-plugin';

const config = plugin(new StatsWebpackPlugin(), {/* webpack config here */});

The available helpers are:

  • entry
  • loader
  • output
  • plugin
  • tap

entry(values, config)

Modify the webpack config entry object.

// Set the `entry` to `index.js`
entry('index.js');

// Append `foo.js` to all existing entrypoints.
entry.append('foo.js');
entry((previous) => [...previous, 'foo.js'])

The entry function takes either a value to add to entry or a function that maps the existing entry values to new ones. The values property is always an array for consistency even though internally webpack can use objects, strings or arrays.

The callback has this signature:

(previous: Array, key: ?String, config: Object) => { ... }

The key property represents the key in object-style entrypoints and config is the existing webpack configuration object.

loader(loader, config)

Add a loader configuration to an existing webpack configuration.

import loader from 'webpack-partial/loader';

const babel = loader({
  test: /\.js$/,
  loader: 'babel-loader',
})
babel(webpackConfig);

output(object, config)

Merge the given output options into the output options in a webpack configuration. You can use it to do things like quickly change the publicPath.

import output from 'webpack-partial/output';
const rebase = output({publicPath: '/somewhere'});
rebase(webpackConfig);

plugin(object, config)

Append a plugin to the existing plugins in a webpack configuration.

import plugin from 'webpack-partial/plugin';
import StatsWebpackPlugin from 'stats-webpack-plugin';

const stats = plugin(new StatsWebpackPlugin())
stats(webpackConfig);

tap(func, config)

Observe the configuration but ignore any modifications. Can be useful to do things like dumping out a configuration.

import tap from 'webpack-partial/tap';
const debug = tap((config) => console.log(config));
debug(webpackConfig);