How to use the @rails/webpacker.devServer.port function in @rails/webpacker

To help you get started, we’ve selected a few @rails/webpacker 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 shakacode / react_on_rails_tutorial_with_ssr_and_hmr_fast_refresh / config / webpack / development.js View on Github external
const developmentEnvOnly = (clientWebpackConfig, serverWebpackConfig) => {

  const isWebpackDevServer = process.env.WEBPACK_DEV_SERVER

  //plugins
  if (isWebpackDevServer) {
    // Note, when this is run, we're building the server and client bundles in separate processes.
    // Thus, this plugin is not applied.
    const ReactRefreshWebpackPlugin = require('@pmmmwh/react-refresh-webpack-plugin')
    clientWebpackConfig.plugins.push(
      new ReactRefreshWebpackPlugin({
        overlay: {
          sockPort: devServer.port
        }
      })
    )
  }

  clientWebpackConfig.plugins.push(
    new ForkTsCheckerWebpackPlugin({
      typescript: {
        configFile: path.resolve(__dirname, '../../tsconfig.json')
      },
      async: false
    })
  )
}