Skip to content
This repository has been archived by the owner on Dec 23, 2019. It is now read-only.

goblin-laboratory/react-app-rewire-entry

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

react-app-rewire-entry

Configure Entry in Create React App without ejecting

Install

$ yarn add react-app-rewire-entry --dev

Add it to your project

/* config-overrides.js */
const paths = require('react-scripts/config/paths');
const rewireEntry = require('react-app-rewire-entry');

paths.appAdminJs = paths.appSrc + '/admin.js';
const {
  rewireWebpackEntryConfig,
  rewireDevServerkEntryConfig,
} = rewireEntry([paths.appIndexJs, paths.appAdminJs]);


module.exports = {
  webpack: (config, env) => {
    config = rewireWebpackEntryConfig(config, env);
    return config;
  },
  devServer: (configFunction) => {
    return (proxy, allowedHost) => {
      let config = configFunction(proxy, allowedHost);
      config = rewireDevServerkEntryConfig(config);
      return config;
    };
  },
};

或者使用下面的方式初始化

const {
  rewireWebpackEntryConfig,
  rewireDevServerkEntryConfig,
} = rewireEntry({
  index: paths.appIndexJs,
  admin: paths.appAdminJs,
});