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
|
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 |
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
|
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 |
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
|
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
|
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 |
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 |
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
|
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
|
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
|
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
|
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 |
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 |
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 |
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 |
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 |
Returns:
devServer config
- Type
- Object
setupHTML(options) → {Object}
Setup HTML with html-webpack-plugin
Parameters:
Name | Type | Description |
---|---|---|
options |
Object | html-webpack-plugin options |
Returns:
Plugin config for html-webpack-plugin
- Type
- Object
splitVendor() → {Object}
Split vendor dependencies from main bundle
Returns:
optimization config
- Type
- Object