diff options
author | Clement Ho <clemmakesapps@gmail.com> | 2018-05-07 22:46:42 +0300 |
---|---|---|
committer | Clement Ho <clemmakesapps@gmail.com> | 2018-05-07 22:46:42 +0300 |
commit | 797a080681233e97ccc0c9ba72431e4b450fff7b (patch) | |
tree | 4bbfcc9c05c033e28c5b8126a09489982b5b1603 /lib | |
parent | ec970e8a3f060986d4e2c0da724c15f6b34587d7 (diff) | |
parent | caf49264b47999a5b888a3ada3b70cc76e94d2bd (diff) |
Merge branch 'upgrade-to-webpack-v4' into 'master'
Upgrade to Webpack 4
Closes #43400
See merge request gitlab-org/gitlab-ce!17218
Diffstat (limited to 'lib')
-rw-r--r-- | lib/gitlab/webpack/dev_server_middleware.rb (renamed from lib/gitlab/middleware/webpack_proxy.rb) | 4 | ||||
-rw-r--r-- | lib/gitlab/webpack/manifest.rb | 27 |
2 files changed, 29 insertions, 2 deletions
diff --git a/lib/gitlab/middleware/webpack_proxy.rb b/lib/gitlab/webpack/dev_server_middleware.rb index 6aecf63231f..b9a75eaac63 100644 --- a/lib/gitlab/middleware/webpack_proxy.rb +++ b/lib/gitlab/webpack/dev_server_middleware.rb @@ -3,8 +3,8 @@ # :nocov: module Gitlab - module Middleware - class WebpackProxy < Rack::Proxy + module Webpack + class DevServerMiddleware < Rack::Proxy def initialize(app = nil, opts = {}) @proxy_host = opts.fetch(:proxy_host, 'localhost') @proxy_port = opts.fetch(:proxy_port, 3808) diff --git a/lib/gitlab/webpack/manifest.rb b/lib/gitlab/webpack/manifest.rb new file mode 100644 index 00000000000..0c343e5bc1d --- /dev/null +++ b/lib/gitlab/webpack/manifest.rb @@ -0,0 +1,27 @@ +require 'webpack/rails/manifest' + +module Gitlab + module Webpack + class Manifest < ::Webpack::Rails::Manifest + # Raised if a supplied asset does not exist in the webpack manifest + AssetMissingError = Class.new(StandardError) + + class << self + def entrypoint_paths(source) + raise ::Webpack::Rails::Manifest::WebpackError, manifest["errors"] unless manifest_bundled? + + entrypoint = manifest["entrypoints"][source] + if entrypoint && entrypoint["assets"] + # Can be either a string or an array of strings. + # Do not include source maps as they are not javascript + [entrypoint["assets"]].flatten.reject { |p| p =~ /.*\.map$/ }.map do |p| + "/#{::Rails.configuration.webpack.public_path}/#{p}" + end + else + raise AssetMissingError, "Can't find entry point '#{source}' in webpack manifest" + end + end + end + end + end +end |