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-cli/webpack-scaffold

v1.0.3

Published

Utility files for webpack-scaffold

Downloads

7,739

Readme

webpack-scaffold

NPM Downloads

This is the utility suite for creating a webpack scaffold, it contains utility functions to help you work with Inquirer prompting and scaffolding.

Installation

npm i -D webpack-cli @webpack-cli/webpack-scaffold

API

parseValue

Param: String

Used when you cannot use regular conventions. Handy for examples like RegExp or output.sourcePrefix

const parseValue = require('@webpack-cli/webpack-scaffold').parseValue;

this.configuration.myScaffold.webpackOptions.output.sourcePrefix = parseValue('\t');
// sourcePrefix: '\t'

createArrowFunction

Param: String

Generally used when dealing with an entry point as an arrow function

const createArrowFunction = require('@webpack-cli/webpack-scaffold').createArrowFunction;

this.configuration.myScaffold.webpackOptions.entry = createArrowFunction('app.js');
// entry: () => 'app.js'

createRegularFunction

Param: String

Used when creating a function that returns a single value

const createRegularFunction = require('@webpack-cli/webpack-scaffold').createRegularFunction;

this.configuration.myScaffold.webpackOptions.entry = createRegularFunction('app.js');
// entry: function() { return 'app.js' }

createDynamicPromise

Param: Array | String

Used to create a dynamic entry point

const createDynamicPromise = require('@webpack-cli/webpack-scaffold').createDynamicPromise;

this.confguration.myScaffold.webpackOptions.entry = createDynamicPromise('app.js');
// entry: () => new Promise((resolve) => resolve('app.js'))

this.configuration.myScaffold.webpackOptions.entry = createDynamicPromise(['app.js', 'index.js']);
// entry: () => new Promise((resolve) => resolve(['app.js','index.js']))

createAssetFilterFunction

Param: String

Used to create an assetFilterFunction

const createAssetFilterFunction = require('@webpack-cli/webpack-scaffold').createAssetFilterFunction;

this.configuration.myScaffold.webpackOptions.performance.assetFilter = createAssetFilterFunction('js');
// assetFilter: function (assetFilename) { return assetFilename.endsWith('.js'); }

createExternalFunction

Param: String

Used to create a general function from Externals

const createExternalFunction = require('@webpack-cli/webpack-scaffold').createExternalFunction;

this.configuration.myScaffold.webpackOptions.externals = [createExternalFunction('^yourregex$')];
/*
externals: [
  function(context, request, callback) {
    if (/^yourregex$/.test(request)){
      return callback(null, 'commonjs ' + request);
    }
    callback();
  }
*/

createRequire

Param: String

Used to create a module in topScope

const createRequire = require('@webpack-cli/webpack-scaffold').createRequire;

this.configuration.myScaffold.topScope = [createRequire('webpack')];
// const webpack = require('webpack')

Inquirer

List

Param: name<String>, message<String>, choices<Array>

Creates a List from Inquirer

const List = require('@webpack-cli/webpack-scaffold').List;

List('entry', 'what kind of entry do you want?', ['Array', 'Function']);

RawList

Param: name<String>, message<String>, choices<Array>

Creates a RawList from Inquirer

const RawList = require('@webpack-cli/webpack-scaffold').RawList;

RawList('entry', 'what kind of entry do you want?', ['Array', 'Function']);

CheckList

Param: name<String>, message<String>, choices<Array>

Creates a CheckList(checkbox) from Inquirer

const CheckList = require('@webpack-cli/webpack-scaffold').CheckList;

CheckList('entry', 'what kind of entry do you want?', ['Array', 'Function']);

Input

Param: name<String>, message<String>, [default<String>]

Creates an Input from Inquirer

const Input = require('@webpack-cli/webpack-scaffold').Input;

Input('entry', 'what is your entry point?', 'src/index');

InputValidate

Param: name<String>, message<String>, [validate<Function>, default<String>]

Creates an Input from Inquirer

const InputValidate = require('@webpack-cli/webpack-scaffold').InputValidate;

const validation = (value) => {
    if (value.length > 4) {
        return true;
    } else {
        return 'Your answer must be longer than 4 characters, try again';
    }
};

InputValidate('entry', 'what is your entry point?', validation, 'src/index');

Confirm

Param: name<String>, message<String>, [default<Boolean>]

Creates an Input from Inquirer

const Confirm = require('@webpack-cli/webpack-scaffold').Confirm;

Confirm('contextConfirm', 'Is this your context?');