Skip to content
GitLab
Projects Groups Snippets
  • /
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
    • Contribute to GitLab
  • Sign in / Register
  • C create-react-app
  • Project information
    • Project information
    • Activity
    • Labels
    • Members
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
  • Issues 1,547
    • Issues 1,547
    • List
    • Boards
    • Service Desk
    • Milestones
  • Merge requests 417
    • Merge requests 417
  • CI/CD
    • CI/CD
    • Pipelines
    • Jobs
    • Schedules
  • Deployments
    • Deployments
    • Environments
    • Releases
  • Packages and registries
    • Packages and registries
    • Package Registry
    • Infrastructure Registry
  • Monitor
    • Monitor
    • Incidents
  • Analytics
    • Analytics
    • Value stream
    • CI/CD
    • Repository
  • Wiki
    • Wiki
  • Snippets
    • Snippets
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
Collapse sidebar
  • Meta
  • create-react-app
  • Merge requests
  • !11806

fix: replace https to server to support Webpack 5

  • Review changes

  • Download
  • Email patches
  • Plain diff
Open Administrator requested to merge github/fork/luffy84217/fix-webpack-dev-server-deprecated-option into main Dec 20, 2021
  • Overview 8
  • Commits 2
  • Pipelines 0
  • Changes 2

Created by: luffy84217

Describe the bug

Project CRA 5, with a .env.development.local file configured with HTTPS settings, gives deprecation warning.

Actual behavior

A deprecation warning is issued on bootstrap, app still works properly. Screenshot: image

Core idea

https://github.com/facebook/create-react-app/blob/20edab4894b301f6b90dad0f90a2f82c52a7ac66/packages/react-scripts/config/webpackDevServer.config.js#L102

Replace https: getHttpsConfig(): { cert: Buffer; key: Buffer; } | boolean with server: getServerConfig(): "http" | "https" | { type: "https"; options: { cert: Buffer; key: Buffer; }; }

function getServerConfig() {
  const { SSL_CRT_FILE, SSL_KEY_FILE, HTTPS } = process.env;
  const protocol = HTTPS === 'true' ? 'https' : 'http';

  if (protocol === 'https') {
    if (SSL_CRT_FILE && SSL_KEY_FILE) {
      const crtFile = path.resolve(paths.appPath, SSL_CRT_FILE);
      const keyFile = path.resolve(paths.appPath, SSL_KEY_FILE);
      const config = {
        type: protocol,
        options: {
          cert: readEnvFile(crtFile, 'SSL_CRT_FILE'),
          key: readEnvFile(keyFile, 'SSL_KEY_FILE'),
        },
      };

      validateKeyAndCerts({ ...config.options, keyFile, crtFile });
      return config;
    }
    return protocol;
  }
  return protocol;
}

Modify the function to move https config into "server" options and align schemas

After fixing

The deprecation warning is eliminated successfully. Screenshot: image

Assignee
Assign to
Reviewers
Request review from
Time tracking
Source branch: github/fork/luffy84217/fix-webpack-dev-server-deprecated-option