0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

Rails, Angular, Postgres, and Bootstrap, Second Editionを読み始めて

Posted at

Pragmatic Programmersの標記の本を読み始めて、本にある通りVagrant開発環境で動かそうと思いハマったので・・・

pdf35ページあたりで、
bundle exec rails webpacker:install
でwebpackerをインストールした後で、
gem 'foreman'
を追加して、bundle install の後でForeman用の設定ファイルProcfileに

Procfile
rails:   bundle exec rails server
webpack: bin/webpack-dev-server

を書いて、foreman start とすれば動くとありましたが、予想通りvagrant環境では動きませんでした。

Procfile
rails:   bundle exec rails server -b 0.0.0.0

に替えて(これは予測できていました)、更に
config/webpacker.yml の中で

config/webpacker.yml
development:
  <<: *default

  dev_server:
    host: 0.0.0.0
    port: 8080
    https: false

host: 0.0.0.0 の部分を、自分のvagrantに設定したアドレス 
192.168.xx.xx に替えたら無事セカンドのサーバーにアクセスできて、
デベロッパーツールのconsoleに、javascriptの結果が表示されます。
と言ってもこれだけですが。

app/javascript/packs/application.js
console.log('Hello World from Webpacker')

因みに foreman start -p 3000 でいつも通りポート3000で動きます。(ヤレヤレ道は遠い)

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?