Socket
Socket
Sign inDemoInstall

react-scripts-rewrite

Package Overview
Dependencies
Maintainers
1
Versions
12
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

react-scripts-rewrite

Override React build Configuration and scripts for Create React App, tweak the create-react-app webpack config(s) without using 'eject' and without creating a fork of the react-scripts.


Version published
Maintainers
1
Created
Source

react-scripts-rewrite

👨🏻‍💻 author: yoneyy (y.tianyuan)

How to install?

  # yarn
  yarn add react-scripts-rewrite -D --registry=https://registry.npmjs.org/

  # npm
  npm i react-scripts-rewrite -D --registry=https://registry.npmjs.org/

How to use?

First create a config-overrides.js configuration file in the project root path, then enter the configuration item. The configuration items are as follows ⬇️

Everything follows webpack🔍 configuration

/*
 * @Author: Yoneyy (y.tianyuan) 
 * @Date: 2022-03-23 03:17:40 
 * @Last Modified by: Yoneyy (y.tianyuan)
 * @Last Modified time: 2022-04-02 19:03:38
 */

const CompressionWebpackPlugin = require("compression-webpack-plugin");

const lessRegex = /\.(less)$/;
const lessModuleRegex = /\.module\.(less)$/;
const stylesUseLoader = [
  'style-loader',
  'css-loader',
  {
    loader: 'less-loader',
    options: {
      lessOptions: {
        javascriptEnabled: true
      },
      webpackImporter: true,
    },
  },
];

module.exports = {
  babels: {
    presets: [
      // for more babel presets see https://babeljs.io/docs/en/presets
    ],
    plugins: [
      [
        "babel-plugin-import",
        {
          libraryName: 'antd',
          libraryDirectory: 'es',
          style: true,
        }
      ]
      // for more babel plugins see https://babeljs.io/docs/en/plugins/
    ]
  },
  rules: [
    {
      test: lessRegex,
      exclude: lessModuleRegex,
      use: stylesUseLoader
    },
    {
      test: lessModuleRegex,
      use: stylesUseLoader
    },
    // use more loaders
    // for more loaders see https://webpack.js.org/loaders/
  ],
  plugins: [
    new CompressionWebpackPlugin({
      test: /\.(css|js)$/,
      threshold: 1024,
      minRatio: 0.9
    })
  ].filter(Boolean)
  // use more plugins
  // for more plugins see https://webpack.js.org/plugins/
}

Keywords

FAQs

Package last updated on 16 Apr 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