How to use the react-dev-utils/WebpackDevServerUtils.prepareProxy function in react-dev-utils

To help you get started, we’ve selected a few react-dev-utils examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github kindlyops / havengrc / webui / scripts / start.js View on Github external
.then(port => {
    if (port == null) {
      // We have not found a port.
      return;
    }
    const protocol = process.env.HTTPS === 'true' ? 'https' : 'http';
    const appName = path.basename(path.dirname(paths.elmPackageJson));
    const urls = prepareUrls(protocol, HOST, port);
    // Create a webpack compiler that is configured with custom messages.
    const compiler = createCompiler(webpack, config, appName, urls);
    // Load proxy config
    const proxySetting = require(paths.elmPackageJson).proxy;
    const proxyConfig = prepareProxy(proxySetting, '/');
    // Serve webpack assets generated by the compiler over a web sever.
    const serverConfig = createDevServerConfig(
      proxyConfig,
      urls.lanUrlForConfig
    );
    const devServer = new WebpackDevServer(compiler, serverConfig);
// Launch WebpackDevServer.
    devServer.listen(port, HOST, err => {
  if (err) {
    return console.log(err);
  }
      if (isInteractive) {
        clearConsole();
      }
      console.log(chalk.cyan('Starting the development server...\n'));
      openBrowser(urls.localUrlForBrowser);
github sprinteins / ghost / scripts / frontend / start.js View on Github external
warnings: (warnings) => devServer.sockWrite(devServer.sockets, 'warnings', warnings),
      errors: (errors) => devServer.sockWrite(devServer.sockets, 'errors', errors),
    };
    // Create a webpack compiler that is configured with custom messages.
    const compiler = createCompiler({
      appName,
      config,
      devSocket,
      urls,
      useYarn,
      useTypeScript,
      webpack,
    });
    // Load proxy config
    const proxySetting = require(paths.appPackageJson).proxy;
    const proxyConfig = prepareProxy(proxySetting, paths.appPublic);
    // Serve webpack assets generated by the compiler over a web server.
    const serverConfig = createDevServerConfig(proxyConfig, urls.lanUrlForConfig);
    const devServer = new WebpackDevServer(compiler, serverConfig);
    // Launch WebpackDevServer.
    devServer.listen(port, HOST, (err) => {
      if (err) {
        return console.log(err);
      }
      if (isInteractive) {
        clearConsole();
      }

      // We used to support resolving modules according to `NODE_PATH`.
      // This now has been deprecated in favor of jsconfig/tsconfig.json
      // This lets you use absolute paths in imports inside large monorepos:
      if (process.env.NODE_PATH) {
github Himenon / code-dependency / packages / view / scripts / develop.ts View on Github external
warnings: warnings => (devServer as any).sockWrite((devServer as any).sockets, "warnings", warnings),
      errors: errors => (devServer as any).sockWrite((devServer as any).sockets, "errors", errors),
    };
    // Create a webpack compiler that is configured with custom messages.
    const compiler = createCompiler({
      appName,
      config,
      devSocket,
      urls,
      useYarn,
      useTypeScript,
      webpack,
    });
    // Load proxy config
    const proxySetting = require(paths.appPackageJson).proxy;
    const proxyConfig = prepareProxy(proxySetting, paths.appPublic);
    // Serve webpack assets generated by the compiler over a web server.
    const serverConfig = createDevServerConfig(proxyConfig, urls.lanUrlForConfig);
    const devServer = new WebpackDevServer(compiler, serverConfig);
    // Launch WebpackDevServer.
    devServer.listen(port, HOST, (err: any) => {
      if (err) {
        return console.log(err);
      }
      if (isInteractive) {
        clearConsole();
      }
      console.log(chalk.cyan("Starting the development server...\n"));
      openBrowser(urls.localUrlForBrowser);
    });

    (["SIGINT", "SIGTERM"] as NodeJS.Signals[]).forEach(sig => {
github Foveluy / Luy / scripts / start.js View on Github external
.then(port => {
        if (port == null) {
            // We have not found a port.
            return;
        }
        const protocol = process.env.HTTPS === 'true' ? 'https' : 'http';
        const appName = require(paths.appPackageJson).name;
        const urls = prepareUrls(protocol, HOST, port);
        // Create a webpack compiler that is configured with custom messages.
        const compiler = createCompiler(webpack, config, appName, urls, useYarn);
        // Load proxy config
        const proxySetting = require(paths.appPackageJson).proxy;
        const proxyConfig = prepareProxy(proxySetting, paths.appPublic);
        // Serve webpack assets generated by the compiler over a web sever.
        const serverConfig = createDevServerConfig(
            proxyConfig,
            urls.lanUrlForConfig
        );
        const devServer = new WebpackDevServer(compiler, serverConfig);
        // Launch WebpackDevServer.
        devServer.listen(port, HOST, err => {
            if (err) {
                return console.log(err);
            }
            if (isInteractive) {
                clearConsole();
            }
            console.log(chalk.cyan('Starting the development server...\n'));
            openBrowser(urls.localUrlForBrowser);
github rintoj / react-ts / scripts / serve.js View on Github external
// Tools like Cloud9 rely on this.
  const port = parseInt(process.env.PORT, 10) || requestedPort || 3000;
  const HOST = process.env.HOST || '0.0.0.0';

  if (port == null) {
    return;
  }
  const protocol = process.env.HTTPS === 'true' ? 'https' : 'http';
  const appName = require(paths.packageJson).name;
  const urls = prepareUrls(protocol, HOST, port);
  // Create a webpack compiler that is configured with custom messages.
  const compiler = createCompiler(webpack, config, appName, urls, useYarn);
  // Load proxy config
  const proxySetting = require(paths.packageJson).proxy;
  const proxyConfig = prepareProxy(proxySetting, paths.appPublic);
  // Serve webpack assets generated by the compiler over a web sever.
  const serverConfig = createDevServerConfig(proxyConfig, urls.lanUrlForConfig);
  const devServer = new WebpackDevServer(compiler, serverConfig);
  // Launch WebpackDevServer.
  devServer.listen(port, HOST, (err) => {
    if (err) {
      console.log(err);
      return;
    }
    if (isInteractive) {
      clearConsole();
    }
    console.log(chalk.cyan('Starting the development server...\n'));
    openBrowser(urls.localUrlForBrowser);
  });
github prisma-labs / graphql-playground / packages / graphql-playground-react / scripts / start.js View on Github external
.then(port => {
  if (port == null) {
  // We have not found a port.
  return;
}
const protocol = process.env.HTTPS === 'true' ? 'https' : 'http';
const appName = require(paths.appPackageJson).name;
const urls = prepareUrls(protocol, HOST, port);
// Create a webpack compiler that is configured with custom messages.
const compiler = createCompiler(webpack, config, appName, urls, useYarn);
// Load proxy config
const proxySetting = require(paths.appPackageJson).proxy;
const proxyConfig = prepareProxy(proxySetting, paths.appPublic);
// Serve webpack assets generated by the compiler over a web sever.
const serverConfig = createDevServerConfig(
  proxyConfig,
  urls.lanUrlForConfig
);
const devServer = new WebpackDevServer(compiler, serverConfig);
// Launch WebpackDevServer.
devServer.listen(port, HOST, err => {
  if (err) {
    return console.log(err);
  }
  if (isInteractive) {
    clearConsole();
  }
  console.log(chalk.cyan('Starting the development server...\n'));
openBrowser(urls.localUrlForBrowser);
github hodgef / js-library-boilerplate / scripts / start.js View on Github external
errors: errors =>
        devServer.sockWrite(devServer.sockets, 'errors', errors),
    };
    // Create a webpack compiler that is configured with custom messages.
    const compiler = createCompiler({
      appName,
      config,
      devSocket,
      urls,
      useYarn,
      useTypeScript,
      webpack,
    });
    // Load proxy config
    const proxySetting = require(paths.appPackageJson).proxy;
    const proxyConfig = prepareProxy(proxySetting, paths.appPublic);
    // Serve webpack assets generated by the compiler over a web server.
    const serverConfig = createDevServerConfig(
      proxyConfig,
      urls.lanUrlForConfig
    );
    const devServer = new WebpackDevServer(compiler, serverConfig);
    // Launch WebpackDevServer.
    devServer.listen(port, HOST, err => {
      if (err) {
        return console.log(err);
      }
      if (isInteractive) {
        clearConsole();
      }

      // We used to support resolving modules according to `NODE_PATH`.
github Yoast / YoastSEO.js / examples / webpack / scripts / start.js View on Github external
.then( port => {
		if ( port == null ) {
			// We have not found a port.
			return;
		}
		const config = configFactory( "development" );
		const protocol = process.env.HTTPS === "true" ? "https" : "http";
		const appName = require( paths.appPackageJson ).name;
		const urls = prepareUrls( protocol, HOST, port );
		// Create a webpack compiler that is configured with custom messages.
		const compiler = createCompiler( webpack, config, appName, urls, useYarn );
		// Load proxy config
		const proxySetting = require( paths.appPackageJson ).proxy;
		const proxyConfig = prepareProxy( proxySetting, paths.appPublic );
		// Serve webpack assets generated by the compiler over a web server.
		const serverConfig = createDevServerConfig(
			proxyConfig,
			urls.lanUrlForConfig
		);
		const devServer = new WebpackDevServer( compiler, serverConfig );
		// Launch WebpackDevServer.
		devServer.listen( port, HOST, err => {
			if ( err ) {
				return console.log( err );
			}
			if ( isInteractive ) {
				clearConsole();
			}
			console.log( chalk.cyan( "Starting the development server...\n" ) );
			openBrowser( urls.localUrlForBrowser );
github nxtedition / create-caspar-graphics / packages / caspar-graphics / scripts / start.js View on Github external
const templates = fs.readdirSync(paths.appTemplates).filter(junk.not)
    const dotenv = getClientEnv({ templates, host, port, mode })
    const config = createConfig({ templates, appName, dotenv })
    const urls = prepareUrls(protocol, host, port)
    const proxySetting = require(paths.appPackageJson).proxy
    const useYarn = fs.existsSync(paths.yarnLockFile);
    const compiler = createCompiler({
      webpack,
      config,
      appName,
      urls,
      useYarn
    })
    const serverConfig = createDevServerConfig(
      config,
      prepareProxy(proxySetting, paths.appPublic),
      urls.lanUrlForConfig
    )

    const devServer = new WebpackDevServer(compiler, serverConfig)

    devServer.listen(port, host, err => {
      if (err) {
        return console.log(err)
      }

      console.clear()
      console.log(chalk.cyan('Starting the development server...\n'))
      openBrowser(urls.localUrlForBrowser)
    })
    ;['SIGINT', 'SIGTERM'].forEach(function(sig) {
      process.on(sig, function() {