webpack-addons
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 = parseValue; thisconfigurationmyScaffoldwebpackOptionsoutputsourcePrefix = // sourcePrefix: '\t'
createArrowFunction
Param: String
Generally used when dealing with an entry point as an arrow function.
const createArrowFunction = createArrowFunction; thisconfigurationmyScaffoldwebpackOptionsentry = // entry: () => 'app.js'
createRegularFunction
Param: String
Used when creating a function that returns a single value.
const createRegularFunction = createRegularFunction; thisconfigurationmyScaffoldwebpackOptionsentry = // entry: function() { return 'app.js' }
createDynamicPromise
Param: Array
| String
Used to create an dynamic entry point.
const createDynamicPromise = createDynamicPromise; thisconfgurationmyScaffoldwebpackOptionsentry = // entry: () => new Promise((resolve) => resolve('app.js')) thisconfigurationmyScaffoldwebpackOptionsentry = // entry: () => new Promise((resolve) => resolve(['app.js','index.js']))
createAssetFilterFunction
Param: String
Used to create an assetFilterFunction
const createAssetFilterFunction = createAssetFilterFunction; thisconfigurationmyScaffoldwebpackOptionsperformanceassetFilter = // assetFilter: function (assetFilename) { return assetFilename.endsWith('.js'); }
createExternalFunction
Param: String
Used to create an general function from Externals
const createExternalFunction = createExternalFunction; thisconfigurationmyScaffoldwebpackOptionsexternals = /*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 = createCommonsChunkPlugin; thisconfigurationmyScaffoldwebpackOptionsplugins = /*plugins: [ new webpack.optimize.CommonsChunkPlugin({ name: 'vendor', filename: 'vendor-[hash].min.js', })*/
createRequire
Param: String
Used to create a module in topScope
const createRequire = createRequire; thisconfigurationmyScaffoldtopScope = // const webpack = require('webpack')
Inquirer
List
Param: name<String>, message<String>, choices<Array>
Creates a List from Inquirer
RawList
Param: name<String>, message<String>, choices<Array>
Creates a RawList from Inquirer
CheckList
Param: name<String>, message<String>, choices<Array>
Creates a CheckList(checkbox
) from Inquirer
Input
Param: name<String>, message<String>
Creates an Input from Inquirer
InputValidate
Param: name<String>, message<String>, validate<Function>
Creates an Input from Inquirer
const validation = { ifvaluelength > 4 return true; else return 'Wow, that was short!' }
Confirm
Param: name<String>, message<String>
Creates an Input from Inquirer