webpacker: pack_tags don't pick up custom host when running webpack-dev-server
Steps to reproduce
- Clone the dummy-webpacker-app I made for this issue
- 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
- 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.
About this issue
- Original URL
- State: closed
- Created 7 years ago
- Comments: 26 (18 by maintainers)
Solved here as well.
docker-compose.yml
webpacker.yml
Thanks guys
Thanks, that worked. I’ve also had to edit webpack settings:
My docker looks like this, now:
@hovancik Try to add
WEBPACKER_DEV_SERVER_HOST: webpacker
to your web serviceBTW, forgot to mention - you won’t get full urls with dev server, the internal proxy will route that for you: https://github.com/rails/webpacker/blob/master/lib/webpacker/dev_server_proxy.rb#L11
Please could you update binstubs:
bundle binstubs webpacker --force