Socket
Socket
Sign inDemoInstall

@webpack-blocks/webpack2

Package Overview
Dependencies
7
Maintainers
1
Versions
7
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    @webpack-blocks/webpack2

Webpack block for the webpack 2.x base configuration.


Version published
Weekly downloads
696
increased by18.57%
Maintainers
1
Created
Weekly downloads
 

Readme

Source

Webpack blocks - Webpack 2 base configuration

JavaScript Style Guide NPM Version

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', [
    // will only enable source maps if `NODE_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.

FAQs

Last updated on 10 Dec 2016

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc