Skip to content

Commit 80f08b2

Browse files
new pr against next branch
1 parent d9fbe44 commit 80f08b2

File tree

13 files changed

+89
-34
lines changed

13 files changed

+89
-34
lines changed

packages/babel-plugin-named-asset-import/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,6 @@
1212
"index.js"
1313
],
1414
"peerDependencies": {
15-
"@babel/core": "7.0.0-beta.38"
15+
"@babel/core": "7.0.0-beta.41"
1616
}
1717
}

packages/babel-preset-react-app/package.json

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -12,19 +12,19 @@
1212
"dependencies.js"
1313
],
1414
"dependencies": {
15-
"@babel/core": "7.0.0-beta.38",
16-
"@babel/plugin-proposal-class-properties": "7.0.0-beta.38",
17-
"@babel/plugin-syntax-dynamic-import": "7.0.0-beta.38",
18-
"@babel/plugin-transform-classes": "7.0.0-beta.38",
19-
"@babel/plugin-transform-destructuring": "7.0.0-beta.38",
20-
"@babel/plugin-transform-react-constant-elements": "7.0.0-beta.38",
21-
"@babel/plugin-transform-react-display-name": "7.0.0-beta.38",
22-
"@babel/plugin-transform-react-jsx": "7.0.0-beta.38",
23-
"@babel/plugin-transform-regenerator": "7.0.0-beta.38",
24-
"@babel/plugin-transform-runtime": "7.0.0-beta.38",
25-
"@babel/preset-env": "7.0.0-beta.38",
26-
"@babel/preset-flow": "7.0.0-beta.38",
27-
"@babel/preset-react": "7.0.0-beta.38",
15+
"@babel/core": "7.0.0-beta.41",
16+
"@babel/plugin-proposal-class-properties": "7.0.0-beta.41",
17+
"@babel/plugin-syntax-dynamic-import": "7.0.0-beta.41",
18+
"@babel/plugin-transform-classes": "7.0.0-beta.41",
19+
"@babel/plugin-transform-destructuring": "7.0.0-beta.41",
20+
"@babel/plugin-transform-react-constant-elements": "7.0.0-beta.41",
21+
"@babel/plugin-transform-react-display-name": "7.0.0-beta.41",
22+
"@babel/plugin-transform-react-jsx": "7.0.0-beta.41",
23+
"@babel/plugin-transform-regenerator": "7.0.0-beta.41",
24+
"@babel/plugin-transform-runtime": "7.0.0-beta.41",
25+
"@babel/preset-env": "7.0.0-beta.41",
26+
"@babel/preset-flow": "7.0.0-beta.41",
27+
"@babel/preset-react": "7.0.0-beta.41",
2828
"babel-plugin-macros": "2.0.0",
2929
"babel-plugin-transform-dynamic-import": "2.0.0",
3030
"babel-plugin-transform-react-remove-prop-types": "0.4.12"

packages/react-dev-utils/WebpackDevServerUtils.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,20 +34,20 @@ if (isSmokeTest) {
3434
};
3535
}
3636

37-
function prepareUrls(protocol, host, port) {
37+
function prepareUrls(protocol, host, port, pathname) {
3838
const formatUrl = hostname =>
3939
url.format({
4040
protocol,
4141
hostname,
4242
port,
43-
pathname: '/',
43+
pathname,
4444
});
4545
const prettyPrintUrl = hostname =>
4646
url.format({
4747
protocol,
4848
hostname,
4949
port: chalk.bold(port),
50-
pathname: '/',
50+
pathname,
5151
});
5252

5353
const isUnspecifiedHost = host === '0.0.0.0' || host === '::';

packages/react-dev-utils/errorOverlayMiddleware.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,9 @@
99
const launchEditor = require('./launchEditor');
1010
const launchEditorEndpoint = require('./launchEditorEndpoint');
1111

12-
module.exports = function createLaunchEditorMiddleware() {
12+
module.exports = function createLaunchEditorMiddleware(servedPathPathname) {
1313
return function launchEditorMiddleware(req, res, next) {
14-
if (req.url.startsWith(launchEditorEndpoint)) {
14+
if (req.url.startsWith(`${servedPathPathname}${launchEditorEndpoint}`)) {
1515
const lineNumber = parseInt(req.query.lineNumber, 10) || 1;
1616
const colNumber = parseInt(req.query.colNumber, 10) || 1;
1717
launchEditor(req.query.fileName, lineNumber, colNumber);

packages/react-dev-utils/noopServiceWorkerMiddleware.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,11 @@
77

88
'use strict';
99

10-
module.exports = function createNoopServiceWorkerMiddleware() {
10+
module.exports = function createNoopServiceWorkerMiddleware(
11+
servedPathPathname
12+
) {
1113
return function noopServiceWorkerMiddleware(req, res, next) {
12-
if (req.url === '/service-worker.js') {
14+
if (req.url === `${servedPathPathname}/service-worker.js`) {
1315
res.setHeader('Content-Type', 'text/javascript');
1416
res.send(
1517
`// This service worker file is effectively a 'no-op' that will reset any

packages/react-dev-utils/package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
"clearConsole.js",
1717
"crossSpawn.js",
1818
"errorOverlayMiddleware.js",
19+
"serveAppMiddleware.js",
1920
"eslintFormatter.js",
2021
"FileSizeReporter.js",
2122
"formatWebpackMessages.js",
@@ -37,7 +38,7 @@
3738
"workspaceUtils.js"
3839
],
3940
"dependencies": {
40-
"@babel/code-frame": "7.0.0-beta.38",
41+
"@babel/code-frame": "7.0.0-beta.41",
4142
"address": "1.0.3",
4243
"browserslist": "2.11.3",
4344
"chalk": "2.3.0",
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
/**
2+
* Copyright (c) 2015-present, Facebook, Inc.
3+
* All rights reserved.
4+
*
5+
* This source code is licensed under the BSD-style license found in the
6+
* LICENSE file in the root directory of this source tree. An additional grant
7+
* of patent rights can be found in the PATENTS file in the same directory.
8+
*/
9+
'use strict';
10+
11+
module.exports = function createServeAppMiddleware(servedPathPathname) {
12+
return function serveAppMiddleware(req, res, next) {
13+
if (servedPathPathname.length > 1 && servedPathPathname !== './') {
14+
if (req.url.indexOf(servedPathPathname) === -1) {
15+
res.redirect(servedPathPathname);
16+
} else {
17+
next();
18+
}
19+
} else {
20+
next();
21+
}
22+
};
23+
};

packages/react-error-overlay/package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,9 +30,9 @@
3030
"lib/index.js"
3131
],
3232
"devDependencies": {
33-
"@babel/code-frame": "7.0.0-beta.38",
34-
"@babel/core": "7.0.0-beta.38",
35-
"@babel/runtime": "7.0.0-beta.38",
33+
"@babel/code-frame": "7.0.0-beta.41",
34+
"@babel/core": "7.0.0-beta.41",
35+
"@babel/runtime": "7.0.0-beta.41",
3636
"anser": "1.4.6",
3737
"babel-core": "^7.0.0-bridge.0",
3838
"babel-eslint": "^8.0.2",

packages/react-scripts/config/webpack.config.dev.js

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010

1111
const autoprefixer = require('autoprefixer');
1212
const path = require('path');
13+
const url = require('url');
1314
const webpack = require('webpack');
1415
const HtmlWebpackPlugin = require('html-webpack-plugin');
1516
const CaseSensitivePathsPlugin = require('case-sensitive-paths-webpack-plugin');
@@ -21,14 +22,18 @@ const getClientEnvironment = require('./env');
2122
const paths = require('./paths');
2223

2324
// Webpack uses `publicPath` to determine where the app is being served from.
24-
// In development, we always serve from the root. This makes config easier.
25-
const publicPath = '/';
25+
// In development, we serve from the root by default. Webpack will serve from
26+
// the relative path of the homepage field if specified.
27+
let publicPath = url.parse(paths.servedPath).pathname || '';
28+
if (publicPath === './') {
29+
publicPath = publicPath.slice(1);
30+
}
2631
// `publicUrl` is just like `publicPath`, but we will provide it to our app
2732
// as %PUBLIC_URL% in `index.html` and `process.env.PUBLIC_URL` in JavaScript.
2833
// Omit trailing slash as %PUBLIC_PATH%/xyz looks better than %PUBLIC_PATH%xyz.
29-
const publicUrl = '';
34+
const publicUrl = paths.servedPath.slice(0, -1) + '/static';
3035
// Get environment variables to inject into our app.
31-
const env = getClientEnvironment(publicUrl);
36+
const env = getClientEnvironment(publicUrl === '.' ? '' : publicUrl);
3237

3338
// Options for PostCSS as we reference these options twice
3439
// Adds vendor prefixing based on your specified browser support in
@@ -85,6 +90,7 @@ module.exports = {
8590
// There are also additional JS chunk files if you use code splitting.
8691
chunkFilename: 'static/js/[name].chunk.js',
8792
// This is the URL that app is served from. We use "/" in development.
93+
// If there is a homepage path defined, it will be served from that instead.
8894
publicPath: publicPath,
8995
// Point sourcemap entries to original disk location (format as URL on Windows)
9096
devtoolModuleFilenameTemplate: info =>

packages/react-scripts/config/webpackDevServer.config.js

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,16 @@
1010

1111
const errorOverlayMiddleware = require('react-dev-utils/errorOverlayMiddleware');
1212
const noopServiceWorkerMiddleware = require('react-dev-utils/noopServiceWorkerMiddleware');
13+
const serveAppMiddleware = require('react-dev-utils/serveAppMiddleware');
1314
const ignoredFiles = require('react-dev-utils/ignoredFiles');
15+
const url = require('url');
1416
const config = require('./webpack.config.dev');
1517
const paths = require('./paths');
18+
const express = require('express');
1619

1720
const protocol = process.env.HTTPS === 'true' ? 'https' : 'http';
1821
const host = process.env.HOST || '0.0.0.0';
22+
const servedPathPathname = url.parse(paths.servedPath).pathname || '';
1923

2024
module.exports = function(proxy, allowedHost) {
2125
return {
@@ -86,18 +90,26 @@ module.exports = function(proxy, allowedHost) {
8690
// Paths with dots should still use the history fallback.
8791
// See https://github.com/facebook/create-react-app/issues/387.
8892
disableDotRule: true,
93+
index: servedPathPathname,
8994
},
9095
public: allowedHost,
9196
proxy,
9297
before(app) {
9398
// This lets us open files from the runtime error overlay.
94-
app.use(errorOverlayMiddleware());
99+
app.use(errorOverlayMiddleware(servedPathPathname));
95100
// This service worker file is effectively a 'no-op' that will reset any
96101
// previous service worker registered for the same host:port combination.
97102
// We do this in development to avoid hitting the production cache if
98103
// it used the same host and port.
99104
// https://github.com/facebook/create-react-app/issues/2272#issuecomment-302832432
100-
app.use(noopServiceWorkerMiddleware());
105+
app.use(noopServiceWorkerMiddleware(servedPathPathname));
106+
// serves the app up from the homepage if specified
107+
app.use(serveAppMiddleware(servedPathPathname));
108+
// serve up static assets
109+
app.use(
110+
`${config.output.publicPath.slice(0, -1)}/static`,
111+
express.static(paths.appPublic)
112+
);
101113
},
102114
};
103115
};

packages/react-scripts/package.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
"version": "1.1.0",
44
"description": "Configuration and scripts for Create React App.",
55
"repository": "facebook/create-react-app",
6+
"homepage": "https://app.knowledgehound.com/supplier",
67
"license": "MIT",
78
"engines": {
89
"node": ">=6"
@@ -21,8 +22,8 @@
2122
"react-scripts": "./bin/react-scripts.js"
2223
},
2324
"dependencies": {
24-
"@babel/core": "7.0.0-beta.38",
25-
"@babel/runtime": "7.0.0-beta.38",
25+
"@babel/core": "7.0.0-beta.41",
26+
"@babel/runtime": "7.0.0-beta.41",
2627
"autoprefixer": "7.2.5",
2728
"babel-core": "7.0.0-bridge.0",
2829
"babel-eslint": "8.2.1",

packages/react-scripts/scripts/start.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ if (process.env.SKIP_PREFLIGHT_CHECK !== 'true') {
2929
}
3030
// @remove-on-eject-end
3131

32+
const url = require('url');
3233
const chalk = require('chalk');
3334
const webpack = require('webpack');
3435
const WebpackDevServer = require('webpack-dev-server');
@@ -56,6 +57,8 @@ if (!checkRequiredFiles([paths.appHtml, paths.appIndexJs])) {
5657
const DEFAULT_PORT = parseInt(process.env.PORT, 10) || 3000;
5758
const HOST = process.env.HOST || '0.0.0.0';
5859

60+
const servedPathPathname = url.parse(paths.servedPath).pathname || '';
61+
5962
if (process.env.HOST) {
6063
console.log(
6164
chalk.cyan(
@@ -89,7 +92,7 @@ checkBrowsers(paths.appPath)
8992
}
9093
const protocol = process.env.HTTPS === 'true' ? 'https' : 'http';
9194
const appName = require(paths.appPackageJson).name;
92-
const urls = prepareUrls(protocol, HOST, port);
95+
const urls = prepareUrls(protocol, HOST, port, servedPathPathname);
9396
// Create a webpack compiler that is configured with custom messages.
9497
const compiler = createCompiler(
9598
webpack,

packages/react-scripts/template/README.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2175,6 +2175,13 @@ To override this, specify the `homepage` in your `package.json`, for example:
21752175
21762176
This will let Create React App correctly infer the root path to use in the generated HTML file.
21772177
2178+
If `homepage` is specified, Create React App will open your browser at the path specified. From the example above, `npm start` would result in:
2179+
2180+
```js
2181+
http://localhost:3000/relativepath
2182+
```
2183+
This also means that in development the paths to the static files will be served out of the `relativepath` directory.
2184+
21782185
**Note**: If you are using `react-router@^4`, you can root `<Link>`s using the `basename` prop on any `<Router>`.<br>
21792186
More information [here](https://reacttraining.com/react-router/web/api/BrowserRouter/basename-string).<br>
21802187
<br>

0 commit comments

Comments
 (0)