Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@dztools/webpack-config-react

Package Overview
Dependencies
Maintainers
1
Versions
19
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@dztools/webpack-config-react

Webpack base, dev, and prod configurations for React + JavaScript templates.

  • 2.4.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
8
decreased by-60%
Maintainers
1
Weekly downloads
 
Created
Source

@dztools/webpack-config-react

Webpack base, dev, and prod configurations for React + JavaScript templates.

npm prettier license

Installation and Dependencies

To install the package:

[npm i -D || yarn add -D] @dztools/webpack-config-react

If peer dependencies are needed, run the following:

[npm i -D || yarn add -D] @hot-loader/react-dom webpack webpack-cli webpack-dev-server

Note: The version of @hot-loader/react-dom must match your local version of react and react-dom.

Usage

In your local webpack.base.js or webpack.common.js file:

const { webpackBaseConfig } = require('@dztools/webpack-config-react');

module.exports = webpackBaseConfig;

In your local webpack.dev.js file:

const { webpackDevConfig } = require('@dztools/webpack-config-react');

module.exports = webpackDevConfig;

In your local webpack.prod.js file:

const { webpackProdConfig } = require('@dztools/webpack-config-react');

module.exports = webpackProdConfig;

Notes

  • This package has been created with the needs of the React Scaffolder Yeoman generator in mind.
  • The base configuration expects both ./src/polyfills.js and ./src/index.jsx to exist for the entry point, and the build will fail if these files are not found.
  • Your React app will also need a local webpack.config.js file responsible for merging dev and prod configs with the base config as needed.

Example, basic webpack.config.js file:

const { merge } = require('webpack-merge');
const baseConfig = require('./build/webpack.base');

const envs = {
  development: 'dev',
  production: 'prod'
};

const env = envs[process.env.NODE_ENV || 'development'];
const envConfig = require(`./build/webpack.${env}.js`);

module.exports = merge(baseConfig, envConfig);

Extending and Customization

For adding or customizing Webpack configuration options, I recommend utilizing the webpack-merge package and documentation. The webpack-merge package allows for efficient Webpack configuration extension and customization.

Basic example:

const path = require('path');
const { merge } = require('webpack-merge');
const { webpackBaseConfig } = require('@dztools/webpack-config-react');

module.exports = merge(webpackBaseConfig, {
  resolve: {
    alias: {
      '@alias': path.resolve('path', 'to', 'directory')
    }
  }
});

License

MIT

Keywords

FAQs

Package last updated on 07 Jun 2022

Did you know?

Socket

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
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc