diff options
author | Mike Greiling <mike@pixelcog.com> | 2017-02-01 22:05:33 +0300 |
---|---|---|
committer | Mike Greiling <mike@pixelcog.com> | 2017-02-02 01:23:26 +0300 |
commit | a2d837a3719187a906b60b9212b0dbf02396cb59 (patch) | |
tree | 08da24dda249c97816cf299e9105ad57bc2e4552 /config | |
parent | 6fffdf7f2e72128eac53adfd734deb4fad8421fa (diff) |
add rack middleware to proxy webpack dev server
Diffstat (limited to 'config')
-rw-r--r-- | config/application.rb | 2 | ||||
-rw-r--r-- | config/gitlab.yml.example | 10 | ||||
-rw-r--r-- | config/initializers/1_settings.rb | 9 | ||||
-rw-r--r-- | config/initializers/static_files.rb | 21 |
4 files changed, 42 insertions, 0 deletions
diff --git a/config/application.rb b/config/application.rb index 4efe73c7798..9088d3c432b 100644 --- a/config/application.rb +++ b/config/application.rb @@ -84,6 +84,8 @@ module Gitlab config.webpack.config_file = "config/webpack.config.js" config.webpack.output_dir = "public/assets/webpack" config.webpack.public_path = "assets/webpack" + + # Webpack dev server configuration is handled in initializers/static_files.rb config.webpack.dev_server.enabled = false # Enable the asset pipeline diff --git a/config/gitlab.yml.example b/config/gitlab.yml.example index 42e5f105d46..2906633fcbc 100644 --- a/config/gitlab.yml.example +++ b/config/gitlab.yml.example @@ -505,6 +505,16 @@ production: &base # Git timeout to read a commit, in seconds timeout: 10 + ## Webpack settings + # If enabled, this will tell rails to serve frontend assets from the webpack-dev-server running + # on a given port instead of serving directly from /assets/webpack. This is only indended for use + # in development. + webpack: + # dev_server: + # enabled: true + # host: localhost + # port: 3808 + # # 5. Extra customization # ========================== diff --git a/config/initializers/1_settings.rb b/config/initializers/1_settings.rb index 4f33aad8693..ea61aa9e047 100644 --- a/config/initializers/1_settings.rb +++ b/config/initializers/1_settings.rb @@ -410,6 +410,15 @@ Settings['gitaly'] ||= Settingslogic.new({}) Settings.gitaly['socket_path'] ||= ENV['GITALY_SOCKET_PATH'] # +# Webpack settings +# +Settings['webpack'] ||= Settingslogic.new({}) +Settings.webpack['dev_server'] ||= Settingslogic.new({}) +Settings.webpack.dev_server['enabled'] ||= false +Settings.webpack.dev_server['host'] ||= 'localhost' +Settings.webpack.dev_server['port'] ||= 3808 + +# # Testing settings # if Rails.env.test? diff --git a/config/initializers/static_files.rb b/config/initializers/static_files.rb index d6dbf8b9fbf..718cdd51782 100644 --- a/config/initializers/static_files.rb +++ b/config/initializers/static_files.rb @@ -12,4 +12,25 @@ if app.config.serve_static_files app.paths["public"].first, app.config.static_cache_control ) + + # If webpack-dev-server is configured, proxy webpack's public directory + # instead of looking for static assets + if Gitlab.config.webpack.dev_server.enabled + app.config.webpack.dev_server.merge!( + enabled: true, + host: Gitlab.config.gitlab.host, + port: Gitlab.config.gitlab.port, + https: Gitlab.config.gitlab.https, + manifest_host: Gitlab.config.webpack.dev_server.host, + manifest_port: Gitlab.config.webpack.dev_server.port, + ) + + app.config.middleware.insert_before( + Gitlab::Middleware::Static, + Gitlab::Middleware::WebpackProxy, + proxy_path: app.config.webpack.public_path, + proxy_host: Gitlab.config.webpack.dev_server.host, + proxy_port: Gitlab.config.webpack.dev_server.port, + ) + end end |