Search code examples
iiswebpackreact-boilerplate

Missing files when deploying react-boilerplate project to IIS


I've successfully generated the production files and run from the node prod server (built into react-boilerplate). When I run the project from the IIS-configured URL, http://localhost/abc/, I get console errors: GET http://localhost/main.21e300b8d1fb516da3f2.js and GET http://localhost/main.7298ab25765cc3b7f65141e9b8a880ff.css

The path appears to be pointing to the root of localhost and doesn't seem to include "/abc".

I've set up my webpack config like so:

module.exports = (options) => ({
    entry: options.entry,
    output: Object.assign({
      path: path.resolve(process.cwd()),
      publicPath: '/',
    }, options.output),...

Is there a setting in my Webpack config I'm missing? Thanks for any help.


Solution

  • It sounds like you've set up your site in IIS as a virtual directory within the IIS site pointing to localhost. The issue here is that any references to / in your site will translate to the root of your site, not the virtual directory.

    Option 1 is to have Default Website point to your applicaiton (instead of the virtual directory). Option 2 is to create a whole new site in IIS and bind it to another port (or port 80 with a host header and a HOSTS entry).

    Looking at your config, what happens if you set publicPath to /abc instead of /?