react-app-rewire-build-dev
Advanced tools
Comparing version 1.0.0 to 1.0.1
@@ -43,3 +43,4 @@ "use strict"; | ||
useHashIndex: true, | ||
outputPath: "/" | ||
outputPath: "/", | ||
hotReloadPort: "3000" | ||
}, userOptions); | ||
@@ -171,2 +172,7 @@ | ||
} | ||
if (outputFilePath.indexOf("bundle.js") !== -1) { | ||
assetSource = assetSource.replace(/window.location.port/g, options.hotReloadPort); | ||
} | ||
fs.writeFileSync(relativeOutputPath.split("?")[0], assetSource); | ||
@@ -173,0 +179,0 @@ log(targetDefinition, chalk.green("[written]"), chalk.magenta("(" + filesize(assetSize) + ")")); |
{ | ||
"name": "react-app-rewire-build-dev", | ||
"version": "1.0.0", | ||
"version": "1.0.1", | ||
"description": "Source code files used by `webpack-dev-server` is rendered in watch mode at user specified directory through override create-react-app webpack configs without ejecting", | ||
@@ -33,8 +33,6 @@ "main": "./dist/index.js", | ||
"scripts": { | ||
"lint": "eslint ./src", | ||
"build": "babel --source-maps --copy-files ./src --out-dir ./dist", | ||
"prepare": "babel --source-maps --copy-files ./src --out-dir ./dist", | ||
"test": "echo 'Please add tests :-('", | ||
"readme": "gitdown ./.README/README.md --output-file ./README.md", | ||
"prepublish": "npm run build" | ||
"prepublish": "npm run build", | ||
"test": "echo \"Error: no test specified\" && exit 1" | ||
}, | ||
@@ -41,0 +39,0 @@ "devDependencies": { |
@@ -5,5 +5,15 @@ # react-app-rewire-build-dev | ||
Source code files used by `webpack-dev-server` is rendered in watch mode at user specified directory through override create-react-app webpack configs without ejecting. | ||
Source code files used by `webpack-dev-server` is rendered in watch mode at user specified directory without ejecting create-react-app. | ||
# Why do I need this? | ||
As of now (21/06/2018), `create-react-app` (more precisely `react-scripts`) does not allow development builds to be written to the disk because it uses `webpackDevServer` to serve your build files and folders ([for good reasons](https://github.com/facebook/create-react-app/issues/1070#issuecomment-261812303)). The problem is that in some cases you need to have these files written to the disk i.e: | ||
* Developing browser extensions using React. | ||
* Incorporating your React application into an existing application. | ||
* Serving your React app with a dedicated backend. | ||
## Installation | ||
@@ -33,2 +43,3 @@ | ||
basename : "<location of subdirectory>" // deploy react-app in a subdirectory /***** optional *****/ | ||
hotReloadPort : "<port of webpack-server>" // default:3000,simply relaod the webpage on changes./***** optional *****/ | ||
} | ||
@@ -35,0 +46,0 @@ |
@@ -38,3 +38,4 @@ const fs = require("fs"); | ||
useHashIndex: true, | ||
outputPath: "/" | ||
outputPath: "/", | ||
hotReloadPort : "3000" | ||
}, | ||
@@ -200,6 +201,3 @@ userOptions | ||
try { | ||
if ( | ||
options.basename && | ||
outputFilePath.indexOf("index.html") !== -1 | ||
) { | ||
if (options.basename && outputFilePath.indexOf("index.html") !== -1) { | ||
assetSource = assetSource | ||
@@ -211,2 +209,7 @@ .replace(/href="/g, `href="${options.basename}`) | ||
} | ||
if (outputFilePath.indexOf("bundle.js") !== -1) { | ||
assetSource = assetSource.replace(/window.location.port/g, options.hotReloadPort ); | ||
} | ||
fs.writeFileSync(relativeOutputPath.split("?")[0], assetSource); | ||
@@ -213,0 +216,0 @@ log( |
Sorry, the diff of this file is not supported yet
No tests
QualityPackage does not have any tests. This is a strong signal of a poorly maintained or low quality package.
Found 1 instance in 1 package
1739716
11
378
52
1