Skip to content

Commit

Permalink
update readme and rename devserver to devServer
Browse files Browse the repository at this point in the history
  • Loading branch information
likun7981 committed Dec 7, 2017
1 parent 83291b1 commit d4ea69b
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 16 deletions.
10 changes: 1 addition & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -192,15 +192,7 @@ module.exports = {
// The function to use to create a webpack dev server configuration when running the development
// server with 'npm run start' or 'yarn start'.
// Example: set the dev server to use a specific certificate in https.
devServer: function(configFunction) {
// Return the replacement function for create-react-app to use to generate the Webpack
// Development Server config. "configFunction" is the function that would normally have
// been used to generate the Webpack Development server config - you can use it to create
// a starting configuration to then modify instead of having to create a config from scratch.
return function(proxy, allowedHost) {
// Create the default config by calling configFunction with the proxy/allowedHost parameters
const config = configFunction(proxy, allowedHost);

devServer: function(config) {
// Change the https certificate options to match your certificate, using the .env file to
// set the file paths & passphrase.
const fs = require('fs');
Expand Down
4 changes: 2 additions & 2 deletions packages/react-app-rewired/config-overrides.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,14 @@ const webpack = typeof override === 'function'
? override
: override.webpack || ((config, env) => config);

const devserver = override.devserver
const devServer = override.devServer
|| ((config) => config);

const jest = override.jest || ((config) => config);

// normalized overrides functions
module.exports = {
webpack,
devserver,
devServer,
jest
};
10 changes: 5 additions & 5 deletions packages/react-app-rewired/scripts/start.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,20 +3,20 @@ process.env.NODE_ENV = process.env.NODE_ENV || "development";
const paths = require("./utils/paths");
const overrides = require('../config-overrides');
const webpackConfigPath = paths.scriptVersion + "/config/webpack.config.dev";
const devserverConfigPath = paths.scriptVersion + "/config/webpackDevServer.config.js";
const devServerConfigPath = paths.scriptVersion + "/config/webpackDevServer.config.js";

// load environment variables from .env files
require(paths.scriptVersion + '/config/env');
// load original configs
const webpackConfig = require(webpackConfigPath);
const devserverConfigFn = require(devserverConfigPath);
const devServerConfigFn = require(devServerConfigPath);
// override config in memory
require.cache[require.resolve(webpackConfigPath)].exports =
overrides.webpack(webpackConfig, process.env.NODE_ENV);

require.cache[require.resolve(devserverConfigPath)].exports = (proxy, allowedHost) => {
config = devserverConfigFn(proxy, allowedHost);
return overrides.devserver(config);
require.cache[require.resolve(devServerConfigPath)].exports = (proxy, allowedHost) => {
config = devServerConfigFn(proxy, allowedHost);
return overrides.devServer(config);
}

// run original script
Expand Down

0 comments on commit d4ea69b

Please sign in to comment.