@io-arc/webpack-settings

webpack build settings.

Usage#

$ npm i @io-arc/webpack-settings
index.ts
import {
stats,
performance,
progressBar,
jsOptimization
} from '@io-arc/webpack-settings'
import progressBarPlugin from 'progress-bar-webpack-plugin'
export default {
// (abbreviation)
optimization: jsOptimization,
stats: stats(),
performance: performance(),
plugins: [new progressBarPlugin(progressBar('task name'))]
}

Variables#

jsOptimization#

Return: webpack.Options.Optimization

Get minify and common logic extraction settings for Babel, TypeScript, and JavaScript frameworks.
The following information will be read automatically.

webpackDefine#

Global constant.
Use with webpack.DefinePlugin.

Return: object

consttypedescription
IS_PRODUCTIONbooleanWhether the build mode is NODE_ENV=production or not
SITE_TITLEstringConfiguration > Site > title
SITE_URLstringConfiguration > Site > url
SITE_AUTHORstringConfiguration > Site > author
SITE_ROOTstringConfiguration > Site > siteRoot

example

webpack.config.ts
import { webpackDefine } from '@io-arc/webpack-settings'
import webpack from 'webpack'
export default {
// (abbreviation)
plugins: [new webpack.DefinePlugin(webpackDefine)]
}

Functions#

stats(stats)#

Return: webpack.Configuration['stats']

A webpack parameter settings.
Parameter types reference to webpack stats

Parameters

paramstypedefaultdescription
stats (optional)boolean | 'normal' | 'none' | 'verose' | 'errors-only' | 'errors-warnings | 'minimal' | Configuration['stats'] | undefined(*1)webpack stats settings

(*1) Default

{
"assets": true,
"assetsSort": "field",
"cached": true,
"cachedAssets": true,
"children": false,
"chunks": false,
"chunkModules": false,
"chunkOrigins": false,
"chunksSort": "field",
"colors": true,
"depth": false,
"entrypoints": false,
"errors": true,
"errorDetails": true,
"hash": undefined,
"modules": false,
"modulesSort": "field",
"publicPath": true,
"reasons": false,
"source": true,
"timings": true,
"version": true,
"warnings": true
}

performance(performance)#

Return: webpack.Configuration['performance']

A webpack performance settings.
Parameter types reference to webpack performance

Parameters

paramstypedefaultdescription
performance (optional)false | Configuration['performance'] | undefined(*2)webpack performance

(*2) Default

{
"hints": "error",
"maxEntrypointSize": 5e6,
"maxAssetSize": 10e6
}

progressBar(task)#

Return: {format: string; clear: boolean}

Using progress-bar-webpack-plugin.
Install required npm i -D progress-bar-webpack-plugin.

Parameters

paramstypedefaultdescription
taskstring-Task name