GithubHelp home page GithubHelp logo

webpack-addons's Introduction

webpack-addons

Build Status

This is the utility suite for creating a webpack addon. It contains utility functions to assist with inquirer prompting and scaffolding.

API

parseValue

Param: String

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

const parseValue = require('webpack-addons').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-addons').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-addons').createRegularFunction;

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

createDynamicPromise

Param: Array | String

Used to create an dynamic entry point.

const createDynamicPromise = require('webpack-addons').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-addons').createAssetFilterFunction;

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

createExternalFunction

Param: String

Used to create an general function from Externals

const createExternalFunction = require('webpack-addons').createExternalFunction;

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

*/

createCommonsChunkPlugin

Param: String

Used to create a general CommonsChunkPlugin.

const createCommonsChunkPlugin = require('webpack-addons').createCommonsChunkPlugin;

this.configuration.myScaffold.webpackOptions.plugins = [createCommonsChunkPlugin('vendor')]
/*
plugins: [
 new webpack.optimize.CommonsChunkPlugin({
    name: 'vendor',
    filename: 'vendor-[hash].min.js',
  })
*/

createRequire

Param: String

Used to create a module in topScope

const createRequire = require('webpack-addons').createRequire;

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

List

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

Creates a List from Inquirer

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

RawList

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

Creates a RawList from Inquirer

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

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

Input

Param: name<String>, message<String>

Creates an Input from Inquirer

Input('entry', 'what is your entry point?')

InputValidate

Param: name<String>, message<String>, validate<Function>

Creates an Input from Inquirer

const validation = (value) => {
    if(value.length > 4) {
        return true;
    } else {
        return 'Wow, that was short!'
    }
}
Input('entry', 'what is your entry point?', validation)

Confirm

Param: name<String>, message<String>

Creates an Input from Inquirer

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

webpack-addons's People

Contributors

evenstensberg avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.