12
11

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.

Rails5.1@webpackerをリモートホストのDocker環境で使うときのメモ

Last updated at Posted at 2017-05-09

この方法はobsoleteかな?↓の方法でどうぞ
Rails5.1@webpackerのDocker環境で使うときのメモ 2017/11/11 - Qiita

はじめに

  • javascript_pack_tagはmanifest.jsonをパースしている
  • 別ホスト上のDockerだと,webpack-dev-serverが認識するアドレスとブラウザから見た時のアドレスが異なるのでmanifest.jsonに記載されているアドレスがブラウザから見て正しくないとget出来ない
  • webpack-dev-serverにhost(ListenするIP)とpublicPath(ブラウザから見た時のホスト名)を教えれば良い
  • dev-serverがブラウザリクエストのHost名をチェックしているので、それを無効化する

関連

変更点

config/webpack/development.server.yml
default: &default
  enabled: true
  host: localhost
  port: 3080              # 今回はこのportにした
development:
  <<: *default
  host: dev0.devopt.local # development環境だけで良いので変更
config/webpack/development.server.js
module.exports = merge(devConfig, {
  devServer: {
//    host: devServer.host, // <- 
    host: "0.0.0.0",        // <- 書き換え
    port: devServer.port,
    compress: true,
    historyApiFallback: true,
    contentBase: resolve(paths.output, paths.entry),
    disableHostCheck: true, // <- 追加
    publicPath
  }
})

出力

BEFORE
$ bin/webpack-dev-server
 10% building modules 2/2 modules 0 active
Project is running at http://localhost:3080/
webpack output is served from http://localhost:3080/packs/
AFTER
$ bin/webpack-dev-server
 10% building modules 2/2 modules 0 active
Project is running at http://0.0.0.0:3080/ 待ち受けアドレス
webpack output is served from http://dev0.devopt.local:3080/packs/ ブラウザからアクセスするURL

12
11
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
12
11

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?