Local server vs Webpack dev server (static files)

Issue Summary

Webpack dev server has no access to static files on LocalWP working port (which are needed for background-image etc), but has access to these assets webpack port, for example 3000. Running without hot reload works ok, because assets are loaded from wp-content/themes/customtheme/assets/ folder

Troubleshooting Questions

  • Does this happen for all sites in Local, or just one in particular?
    It seems that problem occurs on all sites. For sure there is a setting problem with webpack or LocalWP.

  • Are you able to create a new, plain WordPress site in Local and access it in a Browser?
    Yes. Site works well

Replication

  1. Webpack Dev server configuration:
if (currentTask == "devFast") {
  config.devtool = "source-map"
  cssConfig.use.unshift("style-loader")
  scssConfig.use.unshift("style-loader")
  config.output = {
    filename: "bundled.js",
    publicPath: "http://localhost:3000/",
  }
  config.devServer = {
    hot: true,
    port: 3000,
    host: "mylocaldomain.local",
    headers: {
      "Access-Control-Allow-Origin": "*",
    },
    allowedHosts: 'all',
    proxy: {
        "!/assets/**": {
          target: "http://mylocaldomain.local",
          secure: false,
          changeOrigin: true,
        },
      },
    static: [
      {
        directory: path.resolve(__dirname, '../', 'assets'),
        publicPath: '/assets',
      },
    ],
    watchFiles: ["./../**/*.php", "./../**/*.js"],
    liveReload: false,
    historyApiFallback: true,
  }
  config.mode = "development"
}
  1. Access to page from http://mylocaldomain.local/ (with assets error 404 from url http://mylocaldomain.local/assets/img/cat.jpg )

  2. Access to page from http://mylocaldomain.local:3000 (with assets success from url http://mylocaldomain.local:3000/assets/img/cat.jpg )

  3. Access to page from http://localhost

  4. Access to page from http://localhost:3000 (with assets success from url http://localhost:3000/assets/img/cat.jpg )

  5. It is unable to use http://localhost:3000 or http://mylocaldomain.local:3000, because all redirects generated by LocalWP are leading to http://mylocaldomain.local (without port 3000).

System Details

  • Which version of Local is being used?

    • 6.1.5+5536
  • What Operating System (OS) and OS version is being used?

    • Windows 10
  • Attach the Local Log. See this Community Forum post for instructions on how to do so:

    • I have no logs

Expected results

  • Ability of using static files. Maybe is there possibility to set LocalWP port on which he is working and wordpress is generating urls?

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.