New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

react-app-rewire-multiple-entry

Package Overview
Dependencies
Maintainers
1
Versions
8
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

react-app-rewire-multiple-entry - npm Package Compare versions

Comparing version 1.0.1 to 2.0.0

49

index.js
'use strict';
const path = require('path');
const fs = require('fs');
const pwd = process.cwd();

@@ -16,2 +17,10 @@ const XXH = require('xxhashjs');

const checkFileExist = function(file){
if (!fs.existsSync(file)) {
throw new Error('File not found: ' + file);
}
}
const defaultEntryName = 'main';
module.exports = function (params) {

@@ -38,5 +47,11 @@ // Prepare Data for Multiple Entry

entry.outPath = entry.outPath.replace(/^\//, '').replace(/\/$/, '');
checkFileExist(entry.template);
const entryPath = path.resolve(pwd, entry.entry);
checkFileExist(entryPath);
return {
name: formatName(entry.entry),
entry: path.resolve(pwd, entry.entry),
entry: entryPath,
template: entry.template,

@@ -50,23 +65,2 @@ outPath: entry.outPath,

return {
addEntryProxy: function (configFunction) {
if(!entries || !entries.length){
return configFunction;
}
if (!configFunction.historyApiFallback) {
configFunction.historyApiFallback = {};
}
if (!configFunction.historyApiFallback.rewrites) {
configFunction.historyApiFallback.rewrites = [];
}
configFunction.historyApiFallback.rewrites = configFunction.historyApiFallback.rewrites.concat(entries.map(function (entry) {
return {
from: entry.pattern,
to: entry.proxyPath
};
}));
return configFunction;
},
addMultiEntry: function (config) {

@@ -77,14 +71,12 @@ if(!entries || !entries.length){

// Mulitple Entry JS
const defaultEntryPath = 'src/index.js';
const defaulEntryName = formatName(defaultEntryPath);
const defaultEntryHTMLPlugin = config.plugins.filter(function(plugin){
return plugin.constructor.name === 'HtmlWebpackPlugin'
})[0];
defaultEntryHTMLPlugin.options.chunks = [defaulEntryName];
defaultEntryHTMLPlugin.options.chunks = [defaultEntryName];
const necessaryEntry = config.entry.filter(function(file){
return file !== appIndexJs;
});
const multipleEntry = {};
multipleEntry[defaulEntryName] = config.entry;
multipleEntry[defaultEntryName] = config.entry;

@@ -107,5 +99,6 @@ entries.forEach(_entry => {

// Multiple Entry Output File
let names = config.output.filename.split('/').reverse();
if (names[0].indexOf('[name]') === -1) {

@@ -112,0 +105,0 @@ names[0] = '[name].' + names[0];

{
"name": "react-app-rewire-multiple-entry",
"version": "1.0.1",
"version": "2.0.0",
"description": "Multiple Entry Support for Create-React-App",

@@ -59,2 +59,2 @@ "main": "index.js",

}
}
}
[React App Rewire Multiple Entry] lets you configure multiple entries in [Create React App]
v1 and v2 without ejecting.
v1, v2 and v3 without ejecting.

@@ -20,19 +20,16 @@ ## Usage

const multipleEntry = require('react-app-rewire-multiple-entry')([{
const multipleEntry = require('react-app-rewire-multiple-entry')([
{
entry: 'src/entry/landing.js',
template: 'public/landing.html'
template: 'public/landing.html',
outPath: '/landing.html'
}]);
}
]);
module.exports = {
webpack: function(config, env){
multipleEntry.addMultiEntry(config);
return config;
},
devServer: function(configFunction) {
multipleEntry.addEntryProxy(configFunction);
return configFunction;
}
}
webpack: function(config, env) {
multipleEntry.addMultiEntry(config);
return config;
}
};
```

@@ -45,7 +42,9 @@

const multipleEntry = require('react-app-rewire-multiple-entry')([{
const multipleEntry = require('react-app-rewire-multiple-entry')([
{
entry: 'src/entry/landing.js',
template: 'public/landing.html'
template: 'public/landing.html',
outPath: '/landing.html'
}]);
}
]);

@@ -55,3 +54,3 @@ const {

override,
overrideDevServer,
overrideDevServer
} = require('customize-cra');

@@ -61,10 +60,6 @@

webpack: override(
multipleEntry.addMultiEntry,
// addBundleVisualizer()
),
devServer: overrideDevServer(
multipleEntry.addEntryProxy
multipleEntry.addMultiEntry
// addBundleVisualizer()
)
};
```

@@ -115,6 +110,2 @@

return config;
},
devServer: function(configFunction) {
multipleEntry.addEntryProxy(configFunction);
return configFunction;
}

@@ -136,3 +127,2 @@ };

- `addEntryProxy` Inject settings for multiple entry in webpack config
- `addMultiEntry` Inject proxy settings used during development phase.

@@ -139,0 +129,0 @@

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