webpack-setup-env
TypeScript icon, indicating that this package has built-in type declarations

1.2.1 • Public • Published

webpack-setup-env

Travis CI node npm

Setup webpack config with additional env property like babel preset options.


Install

$ npm install webpack-setup-env

Usage

// webpack.config.js
const path = require('path');
const webpack = require('webpack');
const webpackSetup = require('webpack-setup-env');

module.exports = webpackSetup({
    output: {
        path: path.resolve(__dirname, 'dist'),
        publicPath: '/'
    },
    module: {...},
    plugins: [new webpack.DefinePlugin({...})],
    resolve: {...},
    env: {
        development: {
            mode: 'development',
            devtool: 'inline-source-map',
            entry: [
                'webpack-hot-middleware/client',
                path.resolve(__dirname, 'src/app.js')
            ],
            output: {
                filename: 'js/app.bundle.js'
            },
            plugins: [...]
        },
        production: {
            mode: 'production',
            entry: [
                path.resolve(__dirname, 'src/app.js')
            ],
            output: {
                filename: 'js/app.[hash].bundle.js'
            },
            plugins: [ ... ]
        },
        ...
    }
});

API

webpackSetup(options)

  • Params:
    • options: <object> - Webpack configuration.
      • options.env[process.env.NODE_ENV] - Webpack configuration
  • Returns: <object> - Merged by lodash.mergeWith

Inspiration

License

MIT © Guntur Poetra

Package Sidebar

Install

npm i webpack-setup-env

Weekly Downloads

2

Version

1.2.1

License

MIT

Unpacked Size

4.56 kB

Total Files

5

Last publish

Collaborators

  • guntur