-
Notifications
You must be signed in to change notification settings - Fork 1.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
pack_tags don't pick up custom host when running webpack-dev-server #863
Comments
@jeromedalbert There is a PR merged on master (to override public option) but yet to be released which consolidates all arguments into one: #843 and allows overriding using env variables instead. Previously, we kinda of had supported everything which made it difficult to manage these options internally, like if you are passing args through CLI but the ruby gem won't know about it etc. So, if you are using master for both gem and npm module you can run it like so: app: bundle exec rails server -p $PORT
webpacker: WEBPACKER_DEV_SERVER_HOST=0.0.0.0 WEBPACKER_DEV_SERVER_PUBLIC=webpacker.dev WEBPACKER_DEV_SERVER_PORT=$PORT WEBPACKER_DEV_SERVER_HTTPS=true ./bin/webpack-dev-server or you could set these env vars in your These settings are also available inside |
I have updated the gem to the latest master, as well as the npm package with When I try your suggestion code above, the webpack-dev-server process doesn't seem to pick up the I think I am doing something wrong but I can't figure out what it is. |
Please could you update binstubs: |
Thanks I was missing the binstub, now the ENV options are picked up by the webpack-dev-server process. The original problem still persists: javascript_pack_tag doesn't point to my |
Don't know if this helps, but here is my {
"application.js": "/packs/application-646d2e5a8a7a5d6f2ecf.js"
} And looking at the webpacker ruby source code, the pack_tags get their value from Should the ruby code prepend the looked up path with the dev_server address? Or should the dev server address be directly in the manifest.json path? |
@jeromedalbert You don't need to set host for webpack dev server:
|
BTW, 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 |
For HTTPS:
For custom domain for dev server:
although you will get SSL error in your console, just open the dev server link and accept the exception. |
Lets keep this open until a new version is released. |
You're right, I don't need to set a webpacker particular host, I just need https through any host for one of my apps, and proxying through I can see that it works for you in your GIF, but for me when an https request is done to
(Maybe related: I am using macOS High Sierra released yesterday, and I recently updated my ruby version to 2.4.2) |
Does it work without https? |
Nevermind, I must have done something wrong, it works! 👍 Thanks for your help & patience! I ended up with your first suggestion:
and made sure to access https://app.dev through https for everything to work. |
Awesome 👍 |
The same issue. I use:
Usually it doesn't work:
But it works if I save packs/application.js and then make a request:
What do I do wrong? |
Are you using invoker and such or just rails server? |
What does mean invoker? I use docker + docker-compose. Here is docker-compose.yml:
I tried with WEBPACKER_DEV_SERVER_* variables and without them. It seems env variables doesn't make any impact |
I guess in my case Docker is guilty. What I found out: |
@evserykh Ahh I see, were you able to fix it? 3.0.2 released. Closing 👍 |
@gauravtiwari I fixed it editing my docker-compose.yml and all works fine.
|
Great 👍 In 3.0.2, we removed |
I'm having the same issue. Adding
after going up, I get:
|
@hovancik Try to add |
Thanks, that worked. I've also had to edit webpack settings:
My docker looks like this, now:
|
Solved here as well. docker-compose.yml version: '3'
services:
webpacker:
build: .
command: bundle exec bin/webpack-dev-server
environment:
- WEBPACKER_DEV_SERVER_HOST=0.0.0.0
volumes:
- .:/app
ports:
- 8080:8080
app:
build: .
command: /bin/sh -c "rm -f /app/tmp/pids/server.pid && rails server -b 0.0.0.0"
working_dir: /app
environment:
- RAILS_ENV=development
- BUNDLE_JOBS=15
- BUNDLE_RETRY=3
- WEBPACKER_DEV_SERVER_HOST=webpacker
volumes:
- .:/app
ports:
- 3000:3000
links:
- postgres
depends_on:
- webpacker
postgres:
image: postgres:9.4
volumes:
- /var/lib/postgresql/data
ports:
- 5432:5432 webpacker.yml default: &default
source_path: app/javascript
source_entry_path: packs
public_output_path: packs
cache_path: tmp/cache/webpacker
# resolved_paths: ['app/assets']
extensions:
- .coffee
- .erb
- .js
- .jsx
- .ts
- .vue
- .sass
- .scss
- .css
- .png
- .svg
- .gif
- .jpeg
- .jpg
development:
<<: *default
dev_server:
https: false
host: 0.0.0.0
port: 8080
public: 0.0.0.0:8080
hmr: false
# Inline should be set to true if using HMR
inline: true
overlay: true
disable_host_check: true
use_local_ip: false
test:
<<: *default
public_output_path: packs-test
production:
<<: *default Thanks guys |
Changing dev_server:
host: 0.0.0.0
port: 3035
public: 0.0.0.0:3035 |
Steps to reproduce
FYI, this app uses Invoker, which is like Foreman but with
.dev
domains and https support. Here is the content of the Procfile:Actual
javascript_pack_tag
produces the following: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 port9001
for the webpacker process):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.
The text was updated successfully, but these errors were encountered: