frequently used webpack config
Install
npm i @nerjs/webpack
or
yarn add @nerjs/webpack
Use
const createWebpackConfig = require('@nerjs/webpack')
// or es6:
import { createWebpackConfig } from '@nerjs/webpack'
const config = createWebpackConfig({ /* ...settings */ })
Settings:
propName | type | required | description | default |
---|---|---|---|---|
context | String | webpack.config context prop | ||
name | String | webpack.config entry name prop | ||
entryPath | String | webpack.config entry path prop | ||
outputPath | String | webpack.config output path prop | ||
publicPath | String | webpack.config output publick path prop | '/' |
|
outputFilename | String | webpack.config output filename prop | './js/[name].js' |
|
watch | Boolean | webpack.config watch prop | process.env.NODE_ENV !== 'production' |
|
mode | String | webpack.config mode prop | `process.env.NODE_ENV | |
devtool | String | webpack.config devtool prop | process.env.NODE_ENV === 'production' ? false : 'inline-source-map' |
|
react | Boolean | Has react preset in babel module.rule | false |
|
reactHot | Boolean | Has react-hot-loader presets, plugins and webpack-hot-middleware | false |
|
gql | Boolean | Add graphql module to rules | false |
|
styled | Boolean | Has styled-components to babel plugins | false |
|
targets | Object | Schema babel module target in preset-env | { browsers: 'last 3 versions' } |
|
env | Object | Environment thrown into a bundle (webpack.DefinePlugin). All variables are wrapped in JSON.stringify()
|
{ 'process.env.NODE_ENV': process.env.NODE_ENV, NODE_ENV: process.env.NODE_ENV } |
|
dotEnv | Boolean | Has webpack plugin dotenv-webpack | false |