Webpack blocks - Webpack 2 base configuration
This is the webpack2
block providing webpack 2 core functionality. Also provides all @webpack-blocks/core
exports for convenience.
Usage
const HtmlWebpackPlugin = require('html-webpack-plugin')
const { addPlugins, createConfig, entryPoint, env, setOutput, sourceMaps, webpack } = require('@webpack-blocks/webpack2')
module.exports = createConfig([
entryPoint('./src/main.js'),
setOutput('./build/bundle.js'),
addPlugins([
new HtmlWebpackPlugin({
inject: true,
template: './index.html'
}),
new webpack.DefinePlugin({
'process.env': JSON.stringify(process.env || 'development')
})
]),
env('development', [
sourceMaps()
])
])
Webpack 2 compatible blocks
There are some webpack loaders and plugins that are only compatible with webpack 2 in a certain version.
Make sure you use the appropriate webpack blocks:
Exports
createConfig(configSetter: Function[]): object
Takes an array of config setters (the functions returned by invoked webpack blocks), invokes them and returns the resulting webpack config object.
env(envName: string, configSetters: Function[]): Function
Applies an array of webpack blocks only if process.env.NODE_ENV
matches the given envName
. If no NODE_ENV
is set, it will be treated as 'development'.
webpack: object
Same as require('webpack')
.
addPlugins(plugins: WebpackPlugin[])
customConfig(webpackConfigSnippet: object)
entryPoint(entryPoint: string|string[]|object)
resolveAliases(aliases: object)
setContext(path: string)
setDevTool(devtool: string)
setOutput(output: string|object)
sourceMaps()
Webpack blocks
Check out the
👉 Main Documentation
Released under the terms of the MIT license.