Skip to content

pack_tags don't pick up custom host when running webpack-dev-server #863

@jeromedalbert

Description

@jeromedalbert

Steps to reproduce

  1. Clone the dummy-webpacker-app I made for this issue
  2. Follow short README instructions.
    FYI, this app uses Invoker, which is like Foreman but with .dev domains and https support. Here is the content of the Procfile:
    app: bundle exec rails server -p $PORT
    webpacker: ./bin/webpack-dev-server --https --host webpacker.dev --port $PORT
    
  3. Go to http://app.dev

Actual

javascript_pack_tag produces the following:

<script src="/packs/application-c5994df31b2a76c55e0a.js"></script>

The browser console complains that it cannot find http://app.dev/packs/application-c5994df31b2a76c55e0a.js. No JS is executed.

Expected

javascript_pack_tag should produce the following (assuming that Invoker chose to use port 9001 for the webpacker process):

<script src="https://webpacker.dev:9001/packs/application-c5994df31b2a76c55e0a.js"></script>

and the browser console output should read Hello World from Webpacker.

Comments

Everything works well if I don't use webpacker-dev-server and let the rails server handle everything.
Everything works well if I just run ./bin/webpack-dev-server manually without any arguments.

The issue came up with Webpacker 3. I had no issue with Webpacker 2.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions