Global

Methods

buildStyles(FnParamsopt) → {Object}

Build styles Runs loaders in this order: 1. Compiles Sass to CSS with sass-loader 2. Runs PostCSS with plugins with postcss-loader 3. Interprets @import and url() like import/require() and resolves them with css-loader Then extracts CSS into separate file with mini-css-extract-plugin. If any loader options are undefined, the loader is not loaded. Loading a loader with no options means you must pass in an empty object.
Parameters:
Name Type Attributes Default Description
FnParams Object <optional>
{} Object of function parameters
Properties
Name Type Attributes Default Description
cssLoaderOptions Object <optional>
css-loader options
miniCssExtractPluginOptions Object <optional>
mini-css-extract-plugin options
postCSSLoaderOptions Object <optional>
postcss-loader options
sassLoaderOptions Object <optional>
sass-loader options
test RegExp <optional>
/\.(s[ac]ss|css)$/i Rule test value
Source:
Returns:
Module & plugin config for css-loader, mini-css-extract-plugin, postcss-loader, and sass-loader
Type
Object

cleanOutput(options) → {Object}

Delete contents of the output directory using clean-webpack-plugin
Parameters:
Name Type Description
options Object clean-webpack-plugin options
Source:
Returns:
Plugin config for clean-webpack-plugin
Type
Object

compileJS(FnParamsopt) → {Object}

Compile JavaScript using babel-loader
Parameters:
Name Type Attributes Default Description
FnParams Object <optional>
{} Object of function parameters
Properties
Name Type Attributes Default Description
exclude Object <optional>
Rule exclude value
include Object <optional>
Rule include value
options Object <optional>
babel-loader options
test RegExp <optional>
/\.m?jsx?$/i Rule test value
Source:
Returns:
Module config for babel-loader
Type
Object

copyFiles(patternsopt, optionsopt) → {Object}

Copy files from one location to another with copy-webpack-plugin
Parameters:
Name Type Attributes Description
patterns Array <optional>
Array of patterns
options Object <optional>
copy-webpack-plugin options
Source:
Returns:
Plugin config for copy-webpack-plugin
Type
Object

emitMedia(FnParamsopt) → {Object}

Emit images into output directory with file-loader
Parameters:
Name Type Attributes Default Description
FnParams Object <optional>
{} Object of function parameters
Properties
Name Type Attributes Default Description
exclude Object <optional>
Rule exclude value
include Object <optional>
Rule include value
options Object <optional>
url-loader options
test RegExp <optional>
/\.(gif|jpe?g|mov|mp4|png)$/i Rule test value
Source:
Returns:
Module config for file-loader
Type
Object

genAssetList(FnParamsopt) → {Object}

Generate bundle asset list with asset-list-webpack-plugin
Parameters:
Name Type Attributes Default Description
FnParams Object <optional>
{} Object of function parameters
Properties
Name Type Attributes Description
format Object <optional>
Format of generated JSON file
key Object <optional>
Set keys used for JSON file
name Object <optional>
Name of generated JSON file
Source:
Returns:
Plugin config for asset-list-webpack-plugin
Type
Object

genSourceMaps(typeopt) → {Object}

Generate JavaScript source maps
Parameters:
Name Type Attributes Description
type string <optional>
Option to control how source maps are generated
Source:
Returns:
devtool config
Type
Object

ignoreNodeModules(optionsopt) → {Object}

Exclude modules from bundle with webpack-node-externals
Parameters:
Name Type Attributes Description
options Object <optional>
webpack-node-externals options
Source:
Returns:
externals config
Type
Object

injectStyles(FnParamsopt) → {Object}

Inject styles Runs loaders in this order: 1. Compiles Sass to CSS with sass-loader 2. Runs PostCSS with Autoprefixer & cssnano plugins 3. Interprets @import and url() like import/require() and resolves them with css-loader 4. Injects CSS into DOM with style-loader If any loader options are undefined, the loader is not loaded. Loading a loader with no options means you must pass in an empty object.
Parameters:
Name Type Attributes Default Description
FnParams Object <optional>
{} Object of function parameters
Properties
Name Type Attributes Default Description
cssLoaderOptions Object <optional>
css-loader options
postCSSLoaderOptions Object <optional>
postcss-loader options
sassLoaderOptions Object <optional>
sass-loader options
styleLoaderOptions Object <optional>
style-loader options
test RegExp <optional>
/\.(s[ac]ss|css)$/i Rule test value
Source:
Returns:
Module & plugin config for css-loader, postcss-loader, sass-loader, and style-loader
Type
Object

inlineMedia(FnParamsopt) → {Object}

Inline images with url-loader If media is too large, then emit images into output directory with file-loader
Parameters:
Name Type Attributes Default Description
FnParams Object <optional>
{} Object of function parameters
Properties
Name Type Attributes Default Description
exclude Object <optional>
Rule exclude value
include Object <optional>
Rule include value
options Object <optional>
url-loader options
test RegExp <optional>
/\.(gif|jpe?g|mov|mp4|png)$/i Rule test value
Source:
Returns:
Module config for url-loader
Type
Object

inlineReactSVGs(FnParamsopt) → {Object}

Use SVGs as React components and inline them with @svgr/webpack
Parameters:
Name Type Attributes Default Description
FnParams Object <optional>
{} Object of function parameters
Properties
Name Type Attributes Default Description
options Object <optional>
@svgr/webpack options
test RegExp <optional>
/\.svg$/i Rule test value
Source:
Returns:
Module config for @svgr/webpack
Type
Object

loadHTMLAsString(FnParamsopt) → {Object}

Load HTML file as string with html-loader
Parameters:
Name Type Attributes Default Description
FnParams Object <optional>
{} Object of function parameters
Properties
Name Type Attributes Default Description
options Object <optional>
html-loader options
test RegExp <optional>
/\.(ejs|html)$/i Rule test value
Source:
Returns:
Module config for html-loader
Type
Object

minifyJS(options) → {Object}

Minify JavaScript with terser-webpack-plugin
Parameters:
Name Type Description
options Object terser-webpack-plugin options
Source:
Returns:
optimization config
Type
Object

purgeCSS(options) → {Object}

Remove unused CSS with purgecss-webpack-plugin
Parameters:
Name Type Description
options Object purgecss-webpack-plugin options
Source:
Returns:
Plugin config for purgecss-webpack-plugin
Type
Object

setFreeVariable(key, value) → {Object}

Set free variable with DefinePlugin
Parameters:
Name Type Description
key string Free variable key
value * Free variable value
Source:
Returns:
Plugin config
Type
Object

setMode(modeopt) → {Object}

Set mode to determine which webpack optimizations to use
Parameters:
Name Type Attributes Description
mode string <optional>
webpack mode configuration optional value
Source:
Returns:
mode config
Type
Object

setupDevServer(devServeropt) → {Object}

Setup development server with webpack-dev-server
Parameters:
Name Type Attributes Description
devServer Object <optional>
devServer options
Source:
Returns:
devServer config
Type
Object

setupHTML(options) → {Object}

Setup HTML with html-webpack-plugin
Parameters:
Name Type Description
options Object html-webpack-plugin options
Source:
Returns:
Plugin config for html-webpack-plugin
Type
Object

splitVendor() → {Object}

Split vendor dependencies from main bundle
Source:
Returns:
optimization config
Type
Object