webpacker 4.2.2 → 5.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (55) hide show
  1. checksums.yaml +4 -4
  2. data/.node-version +1 -1
  3. data/.travis.yml +7 -20
  4. data/CHANGELOG.md +32 -0
  5. data/Gemfile +1 -0
  6. data/Gemfile.lock +8 -5
  7. data/README.md +52 -280
  8. data/docs/css.md +3 -4
  9. data/docs/deployment.md +2 -2
  10. data/docs/docker.md +17 -17
  11. data/docs/engines.md +13 -0
  12. data/docs/env.md +0 -2
  13. data/docs/integrations.md +220 -0
  14. data/docs/testing.md +1 -2
  15. data/docs/typescript.md +48 -28
  16. data/lib/install/config/webpacker.yml +0 -4
  17. data/lib/install/examples/react/tsconfig.json +2 -1
  18. data/lib/install/examples/typescript/tsconfig.json +2 -1
  19. data/lib/install/loaders/svelte.js +2 -2
  20. data/lib/install/template.rb +1 -1
  21. data/lib/install/typescript.rb +5 -12
  22. data/lib/tasks/webpacker/check_node.rake +14 -7
  23. data/lib/tasks/webpacker/check_yarn.rake +16 -9
  24. data/lib/tasks/webpacker/clean.rake +12 -6
  25. data/lib/tasks/webpacker/clobber.rake +8 -4
  26. data/lib/tasks/webpacker/yarn_install.rake +5 -16
  27. data/lib/webpacker/commands.rb +33 -9
  28. data/lib/webpacker/compiler.rb +2 -3
  29. data/lib/webpacker/configuration.rb +1 -5
  30. data/lib/webpacker/dev_server_proxy.rb +3 -1
  31. data/lib/webpacker/dev_server_runner.rb +4 -4
  32. data/lib/webpacker/helper.rb +12 -12
  33. data/lib/webpacker/manifest.rb +4 -4
  34. data/lib/webpacker/railtie.rb +0 -43
  35. data/lib/webpacker/version.rb +1 -1
  36. data/package.json +35 -35
  37. data/package/__tests__/dev_server.js +2 -0
  38. data/package/dev_server.js +1 -1
  39. data/package/environments/__tests__/base.js +10 -0
  40. data/package/environments/base.js +12 -1
  41. data/package/environments/development.js +0 -4
  42. data/package/rules/babel.js +1 -1
  43. data/package/rules/sass.js +7 -1
  44. data/test/manifest_test.rb +37 -6
  45. data/test/rake_tasks_test.rb +11 -0
  46. data/test/test_app/app/javascript/packs/multi_entry.css +4 -0
  47. data/test/test_app/app/javascript/packs/multi_entry.js +4 -0
  48. data/test/test_app/config/application.rb +0 -1
  49. data/webpacker.gemspec +4 -3
  50. data/yarn.lock +2627 -1547
  51. metadata +28 -13
  52. data/gemfiles/Gemfile-rails.4.2.x +0 -9
  53. data/gemfiles/Gemfile-rails.5.0.x +0 -9
  54. data/gemfiles/Gemfile-rails.5.1.x +0 -9
  55. data/lib/install/loaders/typescript.js +0 -11
@@ -6,7 +6,6 @@ default: &default
6
6
  public_root_path: public
7
7
  public_output_path: packs
8
8
  cache_path: tmp/cache/webpacker
9
- check_yarn_integrity: false
10
9
  webpack_compile_output: true
11
10
 
12
11
  # Additional paths webpack should lookup modules
@@ -52,9 +51,6 @@ development:
52
51
  <<: *default
53
52
  compile: true
54
53
 
55
- # Verifies that correct packages and versions are installed by inspecting package.json, yarn.lock, and node_modules
56
- check_yarn_integrity: true
57
-
58
54
  # Reference: https://webpack.js.org/configuration/dev-server/
59
55
  dev_server:
60
56
  https: false
@@ -8,7 +8,8 @@
8
8
  "moduleResolution": "node",
9
9
  "sourceMap": true,
10
10
  "target": "es5",
11
- "jsx": "react"
11
+ "jsx": "react",
12
+ "noEmit": true
12
13
  },
13
14
  "exclude": [
14
15
  "**/*.spec.ts",
@@ -11,7 +11,8 @@
11
11
  "*": ["node_modules/*", "app/javascript/*"]
12
12
  },
13
13
  "sourceMap": true,
14
- "target": "es5"
14
+ "target": "es5",
15
+ "noEmit": true
15
16
  },
16
17
  "exclude": [
17
18
  "**/*.spec.ts",
@@ -1,9 +1,9 @@
1
1
  module.exports = {
2
- test: /\.svelte$/,
2
+ test: /\.svelte(\.erb)?$/,
3
3
  use: [{
4
4
  loader: 'svelte-loader',
5
5
  options: {
6
- hotReload: true
6
+ hotReload: false
7
7
  }
8
8
  }],
9
9
  }
@@ -1,7 +1,7 @@
1
1
  # Install Webpacker
2
2
  copy_file "#{__dir__}/config/webpacker.yml", "config/webpacker.yml"
3
3
 
4
- puts "Copying webpack core config"
4
+ say "Copying webpack core config"
5
5
  directory "#{__dir__}/config/webpack", "config/webpack"
6
6
 
7
7
  say "Copying postcss.config.js to app root directory"
@@ -15,17 +15,10 @@ if File.exist?(package_json)
15
15
  end
16
16
  end
17
17
 
18
- say "Copying typescript loader to config/webpack/loaders"
19
- copy_file "#{__dir__}/loaders/typescript.js", Rails.root.join("config/webpack/loaders/typescript.js").to_s
20
-
21
- say "Adding typescript loader to config/webpack/environment.js"
22
- insert_into_file Rails.root.join("config/webpack/environment.js").to_s,
23
- "const typescript = require('./loaders/typescript')\n",
24
- after: /require\(('|")@rails\/webpacker\1\);?\n/
25
-
26
- insert_into_file Rails.root.join("config/webpack/environment.js").to_s,
27
- "environment.loaders.prepend('typescript', typescript)\n",
28
- before: "module.exports"
18
+ say "Adding TypeScript preset to babel.config.js"
19
+ insert_into_file Rails.root.join("babel.config.js").to_s,
20
+ ",\n ['@babel/preset-typescript', { 'allExtensions': true, 'isTSX': true }]",
21
+ before: /\s*\].filter\(Boolean\),\n\s*plugins: \[/
29
22
 
30
23
  say "Copying tsconfig.json to the Rails root directory for typescript"
31
24
  copy_file "#{__dir__}/examples/#{example_source}/tsconfig.json", "tsconfig.json"
@@ -41,6 +34,6 @@ copy_file "#{__dir__}/examples/typescript/hello_typescript.ts",
41
34
  "#{Webpacker.config.source_entry_path}/hello_typescript.ts"
42
35
 
43
36
  say "Installing all typescript dependencies"
44
- run "yarn add typescript ts-loader #{additional_packages}"
37
+ run "yarn add typescript @babel/preset-typescript #{additional_packages}"
45
38
 
46
39
  say "Webpacker now supports typescript 🎉", :green
@@ -1,3 +1,4 @@
1
+ require "semantic_range"
1
2
  namespace :webpacker do
2
3
  desc "Verifies if Node.js is installed"
3
4
  task :check_node do
@@ -6,19 +7,25 @@ namespace :webpacker do
6
7
  raise Errno::ENOENT if node_version.blank?
7
8
 
8
9
  pkg_path = Pathname.new("#{__dir__}/../../../package.json").realpath
9
- node_requirement = JSON.parse(pkg_path.read)["engines"]["node"]
10
+ node_range = JSON.parse(pkg_path.read)["engines"]["node"]
11
+ is_valid = SemanticRange.satisfies?(node_version, node_range) rescue false
12
+ semver_major = node_version[/\d+/] rescue nil
13
+ is_unstable = semver_major.to_i.odd? rescue false
10
14
 
11
- requirement = Gem::Requirement.new(node_requirement)
12
- version = Gem::Version.new(node_version.strip.tr("v", ""))
15
+ if is_unstable
16
+ $stderr.puts "Warning: you are using an unstable release of Node.js (#{node_version}). If you encounter issues with Node.js, consider switching to an Active LTS release. More info: https://docs.npmjs.com/try-the-latest-stable-version-of-node"
17
+ end
13
18
 
14
- unless requirement.satisfied_by?(version)
15
- $stderr.puts "Webpacker requires Node.js #{requirement} and you are using #{version}"
19
+ unless is_valid
20
+ $stderr.puts "Webpacker requires Node.js \"#{node_range}\" and you are using #{node_version}"
16
21
  $stderr.puts "Please upgrade Node.js https://nodejs.org/en/download/"
17
- $stderr.puts "Exiting!" && exit!
22
+ $stderr.puts "Exiting!"
23
+ exit!
18
24
  end
19
25
  rescue Errno::ENOENT
20
26
  $stderr.puts "Node.js not installed. Please download and install Node.js https://nodejs.org/en/download/"
21
- $stderr.puts "Exiting!" && exit!
27
+ $stderr.puts "Exiting!"
28
+ exit!
22
29
  end
23
30
  end
24
31
  end
@@ -1,3 +1,4 @@
1
+ require "semantic_range"
1
2
  namespace :webpacker do
2
3
  desc "Verifies if Yarn is installed"
3
4
  task :check_yarn do
@@ -6,19 +7,25 @@ namespace :webpacker do
6
7
  raise Errno::ENOENT if yarn_version.blank?
7
8
 
8
9
  pkg_path = Pathname.new("#{__dir__}/../../../package.json").realpath
9
- yarn_requirement = JSON.parse(pkg_path.read)["engines"]["yarn"]
10
+ yarn_range = JSON.parse(pkg_path.read)["engines"]["yarn"]
11
+ is_valid = SemanticRange.satisfies?(yarn_version, yarn_range) rescue false
12
+ is_unsupported = SemanticRange.satisfies?(yarn_version, ">=2.0.0") rescue false
10
13
 
11
- requirement = Gem::Requirement.new(yarn_requirement)
12
- version = Gem::Version.new(yarn_version)
13
-
14
- unless requirement.satisfied_by?(version)
15
- $stderr.puts "Webpacker requires Yarn #{requirement} and you are using #{version}"
16
- $stderr.puts "Please upgrade Yarn https://yarnpkg.com/lang/en/docs/install/"
17
- $stderr.puts "Exiting!" && exit!
14
+ unless is_valid
15
+ $stderr.puts "Webpacker requires Yarn \"#{yarn_range}\" and you are using #{yarn_version}"
16
+ if is_unsupported
17
+ $stderr.puts "This version of Webpacker does not support Yarn #{yarn_version}. Please downgrade to a supported version of Yarn https://yarnpkg.com/lang/en/docs/install/"
18
+ $stderr.puts "For information on using Webpacker with Yarn 2.0, see https://github.com/rails/webpacker/issues/2112"
19
+ else
20
+ $stderr.puts "Please upgrade Yarn https://yarnpkg.com/lang/en/docs/install/"
21
+ end
22
+ $stderr.puts "Exiting!"
23
+ exit!
18
24
  end
19
25
  rescue Errno::ENOENT
20
26
  $stderr.puts "Yarn not installed. Please download and install Yarn from https://yarnpkg.com/lang/en/docs/install/"
21
- $stderr.puts "Exiting!" && exit!
27
+ $stderr.puts "Exiting!"
28
+ exit!
22
29
  end
23
30
  end
24
31
  end
@@ -4,16 +4,22 @@ require "webpacker/configuration"
4
4
 
5
5
  namespace :webpacker do
6
6
  desc "Remove old compiled webpacks"
7
- task :clean, [:keep] => ["webpacker:verify_install", :environment] do |_, args|
7
+ task :clean, [:keep, :age] => ["webpacker:verify_install", :environment] do |_, args|
8
8
  Webpacker.ensure_log_goes_to_stdout do
9
- Webpacker.clean(Integer(args.keep || 2))
9
+ Webpacker.clean(Integer(args.keep || 2), Integer(args.age || 3600))
10
10
  end
11
11
  end
12
12
  end
13
13
 
14
- # Run clean if the assets:clean is run
15
- if Rake::Task.task_defined?("assets:clean")
16
- Rake::Task["assets:clean"].enhance do
17
- Rake::Task["webpacker:clean"].invoke
14
+ skip_webpacker_clean = %w(no false n f).include?(ENV["WEBPACKER_PRECOMPILE"])
15
+
16
+ unless skip_webpacker_clean
17
+ # Run clean if the assets:clean is run
18
+ if Rake::Task.task_defined?("assets:clean")
19
+ Rake::Task["assets:clean"].enhance do
20
+ Rake::Task["webpacker:clean"].invoke
21
+ end
22
+ else
23
+ Rake::Task.define_task("assets:clean" => "webpacker:clean")
18
24
  end
19
25
  end
@@ -8,9 +8,13 @@ namespace :webpacker do
8
8
  end
9
9
  end
10
10
 
11
- # Run clobber if the assets:clobber is run
12
- if Rake::Task.task_defined?("assets:clobber")
13
- Rake::Task["assets:clobber"].enhance do
14
- Rake::Task["webpacker:clobber"].invoke
11
+ skip_webpacker_clobber = %w(no false n f).include?(ENV["WEBPACKER_PRECOMPILE"])
12
+
13
+ unless skip_webpacker_clobber
14
+ # Run clobber if the assets:clobber is run
15
+ if Rake::Task.task_defined?("assets:clobber")
16
+ Rake::Task["assets:clobber"].enhance do
17
+ Rake::Task["webpacker:clobber"].invoke
18
+ end
15
19
  end
16
20
  end
@@ -1,21 +1,10 @@
1
1
  namespace :webpacker do
2
2
  desc "Support for older Rails versions. Install all JavaScript dependencies as specified via Yarn"
3
3
  task :yarn_install do
4
- system "yarn install --no-progress"
5
-
6
- exit(1) unless $?.success?
4
+ valid_node_envs = %w[test development production]
5
+ node_env = ENV.fetch("NODE_ENV") do
6
+ valid_node_envs.include?(Rails.env) ? Rails.env : "production"
7
+ end
8
+ system({ "NODE_ENV" => node_env }, "yarn install --no-progress --frozen-lockfile")
7
9
  end
8
10
  end
9
-
10
- def enhance_yarn_install
11
- Rake::Task["yarn:install"].enhance do
12
- exit(1) unless $?.success?
13
- end
14
- end
15
-
16
- if Rake::Task.task_defined?("yarn:install")
17
- enhance_yarn_install
18
- else
19
- # this is mainly for pre-5.x era
20
- Rake::Task.define_task("yarn:install" => "webpacker:yarn_install")
21
- end
@@ -5,12 +5,34 @@ class Webpacker::Commands
5
5
  @webpacker = webpacker
6
6
  end
7
7
 
8
- def clean(count = 2)
9
- if config.public_output_path.exist? && config.public_manifest_path.exist? && versions.count > count
10
- versions.drop(count).flat_map(&:last).each do |file|
11
- File.delete(file) if File.file?(file)
12
- logger.info "Removed #{file}"
13
- end
8
+ # Cleanup old assets in the compile directory. By default it will
9
+ # keep the latest version, 2 backups created within the past hour.
10
+ #
11
+ # Examples
12
+ #
13
+ # To force only 1 backup to be kept, set count=1 and age=0.
14
+ #
15
+ # To only keep files created within the last 10 minutes, set count=0 and
16
+ # age=600.
17
+ #
18
+ def clean(count = 2, age = 3600)
19
+ if config.public_output_path.exist? && config.public_manifest_path.exist?
20
+ versions
21
+ .sort
22
+ .reverse
23
+ .each_with_index
24
+ .drop_while do |(mtime, _), index|
25
+ max_age = [0, Time.now - Time.at(mtime)].max
26
+ max_age < age && index < count
27
+ end
28
+ .each do |(_, files), index|
29
+ files.each do |file|
30
+ if File.file?(file)
31
+ File.delete(file)
32
+ logger.info "Removed #{file}"
33
+ end
34
+ end
35
+ end
14
36
  end
15
37
 
16
38
  true
@@ -37,14 +59,16 @@ class Webpacker::Commands
37
59
  manifest_config = Dir.glob("#{config.public_manifest_path}*")
38
60
 
39
61
  packs = all_files - manifest_config - current_version
40
- packs.group_by { |file| File.mtime(file).utc.to_i }.sort.reverse
62
+ packs.reject { |file| File.directory?(file) }.group_by { |file| File.mtime(file).utc.to_i }
41
63
  end
42
64
 
43
65
  def current_version
44
- manifest.refresh.values.map do |value|
66
+ packs = manifest.refresh.values.map do |value|
45
67
  next if value.is_a?(Hash)
46
68
 
47
- File.join(config.root_path, "public", value)
69
+ File.join(config.root_path, "public", "#{value}*")
48
70
  end.compact
71
+
72
+ Dir.glob(packs).uniq
49
73
  end
50
74
  end
@@ -20,9 +20,8 @@ class Webpacker::Compiler
20
20
  if stale?
21
21
  run_webpack.tap do |success|
22
22
  # We used to only record the digest on success
23
- # However, the output file is still written on error, (at least with ts-loader), meaning that the
24
- # digest should still be updated. If it's not, you can end up in a situation where a recompile doesn't
25
- # take place when it should.
23
+ # However, the output file is still written on error, meaning that the digest should still be updated.
24
+ # If it's not, you can end up in a situation where a recompile doesn't take place when it should.
26
25
  # See https://github.com/rails/webpacker/issues/2113
27
26
  record_compilation_digest
28
27
  end
@@ -64,11 +64,7 @@ class Webpacker::Configuration
64
64
  end
65
65
 
66
66
  def check_yarn_integrity=(value)
67
- data[:check_yarn_integrity] = value
68
- end
69
-
70
- def check_yarn_integrity?
71
- fetch(:check_yarn_integrity)
67
+ warn "Webpacker::Configuration#check_yarn_integrity=(value) has been deprecated. The integrity check has been removed from Webpacker so changing this setting will have no effect."
72
68
  end
73
69
 
74
70
  def webpack_compile_output?
@@ -11,7 +11,9 @@ class Webpacker::DevServerProxy < Rack::Proxy
11
11
 
12
12
  def perform_request(env)
13
13
  if env["PATH_INFO"].start_with?("/#{public_output_uri_path}") && dev_server.running?
14
- env["HTTP_HOST"] = env["HTTP_X_FORWARDED_HOST"] = env["HTTP_X_FORWARDED_SERVER"] = dev_server.host_with_port
14
+ env["HTTP_HOST"] = env["HTTP_X_FORWARDED_HOST"] = dev_server.host
15
+ env["HTTP_X_FORWARDED_SERVER"] = dev_server.host_with_port
16
+ env["HTTP_PORT"] = env["HTTP_X_FORWARDED_PORT"] = dev_server.port.to_s
15
17
  env["HTTP_X_FORWARDED_PROTO"] = env["HTTP_X_FORWARDED_SCHEME"] = dev_server.protocol
16
18
  unless dev_server.https?
17
19
  env["HTTPS"] = env["HTTP_X_FORWARDED_SSL"] = "off"
@@ -16,20 +16,20 @@ module Webpacker
16
16
  def load_config
17
17
  app_root = Pathname.new(@app_path)
18
18
 
19
- config = Configuration.new(
19
+ @config = Configuration.new(
20
20
  root_path: app_root,
21
21
  config_path: app_root.join("config/webpacker.yml"),
22
22
  env: ENV["RAILS_ENV"]
23
23
  )
24
24
 
25
- dev_server = DevServer.new(config)
25
+ dev_server = DevServer.new(@config)
26
26
 
27
27
  @hostname = dev_server.host
28
28
  @port = dev_server.port
29
29
  @pretty = dev_server.pretty?
30
30
 
31
31
  rescue Errno::ENOENT, NoMethodError
32
- $stdout.puts "webpack dev_server configuration not found in #{config.config_path}[#{ENV["RAILS_ENV"]}]."
32
+ $stdout.puts "webpack dev_server configuration not found in #{@config.config_path}[#{ENV["RAILS_ENV"]}]."
33
33
  $stdout.puts "Please run bundle exec rails webpacker:install to install Webpacker"
34
34
  exit!
35
35
  end
@@ -39,7 +39,7 @@ module Webpacker
39
39
  server.close
40
40
 
41
41
  rescue Errno::EADDRINUSE
42
- $stdout.puts "Another program is running on port #{@port}. Set a new port in #{@config_file} for dev_server"
42
+ $stdout.puts "Another program is running on port #{@port}. Set a new port in #{@config.config_path} for dev_server"
43
43
  exit!
44
44
  end
45
45
 
@@ -7,8 +7,8 @@ module Webpacker::Helper
7
7
  end
8
8
 
9
9
  # Computes the relative path for a given Webpacker asset.
10
- # Returns the relative path using manifest.json and passes it to asset_path helper.
11
- # This will use asset_path internally, so most of their behaviors will be the same.
10
+ # Returns the relative path using manifest.json and passes it to path_to_asset helper.
11
+ # This will use path_to_asset internally, so most of their behaviors will be the same.
12
12
  #
13
13
  # Example:
14
14
  #
@@ -19,13 +19,13 @@ module Webpacker::Helper
19
19
  # <%= asset_pack_path 'calendar.css' %> # => "/packs/calendar-1016838bab065ae1e122.css"
20
20
  def asset_pack_path(name, **options)
21
21
  if current_webpacker_instance.config.extract_css? || !stylesheet?(name)
22
- asset_path(current_webpacker_instance.manifest.lookup!(name), options)
22
+ path_to_asset(current_webpacker_instance.manifest.lookup!(name), options)
23
23
  end
24
24
  end
25
25
 
26
26
  # Computes the absolute path for a given Webpacker asset.
27
- # Returns the absolute path using manifest.json and passes it to asset_url helper.
28
- # This will use asset_url internally, so most of their behaviors will be the same.
27
+ # Returns the absolute path using manifest.json and passes it to url_to_asset helper.
28
+ # This will use url_to_asset internally, so most of their behaviors will be the same.
29
29
  #
30
30
  # Example:
31
31
  #
@@ -36,7 +36,7 @@ module Webpacker::Helper
36
36
  # <%= asset_pack_url 'calendar.css' %> # => "http://example.com/packs/calendar-1016838bab065ae1e122.css"
37
37
  def asset_pack_url(name, **options)
38
38
  if current_webpacker_instance.config.extract_css? || !stylesheet?(name)
39
- asset_url(current_webpacker_instance.manifest.lookup!(name), options)
39
+ url_to_asset(current_webpacker_instance.manifest.lookup!(name), options)
40
40
  end
41
41
  end
42
42
 
@@ -61,7 +61,7 @@ module Webpacker::Helper
61
61
  end
62
62
 
63
63
  # Creates a script tag that references the named pack file, as compiled by webpack per the entries list
64
- # in config/webpack/shared.js. By default, this list is auto-generated to match everything in
64
+ # in package/environments/base.js. By default, this list is auto-generated to match everything in
65
65
  # app/javascript/packs/*.js. In production mode, the digested reference is automatically looked up.
66
66
  #
67
67
  # Example:
@@ -73,7 +73,7 @@ module Webpacker::Helper
73
73
  end
74
74
 
75
75
  # Creates script tags that reference the js chunks from entrypoints when using split chunks API,
76
- # as compiled by webpack per the entries list in config/webpack/shared.js.
76
+ # as compiled by webpack per the entries list in package/environments/base.js.
77
77
  # By default, this list is auto-generated to match everything in
78
78
  # app/javascript/packs/*.js and all the dependent chunks. In production mode, the digested reference is automatically looked up.
79
79
  # See: https://webpack.js.org/plugins/split-chunks-plugin/
@@ -110,7 +110,7 @@ module Webpacker::Helper
110
110
  end
111
111
 
112
112
  # Creates a link tag that references the named pack file, as compiled by webpack per the entries list
113
- # in config/webpack/shared.js. By default, this list is auto-generated to match everything in
113
+ # in package/environments/base.js. By default, this list is auto-generated to match everything in
114
114
  # app/javascript/packs/*.js. In production mode, the digested reference is automatically looked up.
115
115
  #
116
116
  # Note: If the development server is running and hot module replacement is active, this will return nothing.
@@ -132,7 +132,7 @@ module Webpacker::Helper
132
132
  end
133
133
 
134
134
  # Creates link tags that reference the css chunks from entrypoints when using split chunks API,
135
- # as compiled by webpack per the entries list in config/webpack/shared.js.
135
+ # as compiled by webpack per the entries list in package/environments/base.js.
136
136
  # By default, this list is auto-generated to match everything in
137
137
  # app/javascript/packs/*.js and all the dependent chunks. In production mode, the digested reference is automatically looked up.
138
138
  # See: https://webpack.js.org/plugins/split-chunks-plugin/
@@ -169,8 +169,8 @@ module Webpacker::Helper
169
169
 
170
170
  def resolve_path_to_image(name)
171
171
  path = name.starts_with?("media/images/") ? name : "media/images/#{name}"
172
- asset_path(current_webpacker_instance.manifest.lookup!(path))
172
+ path_to_asset(current_webpacker_instance.manifest.lookup!(path))
173
173
  rescue
174
- asset_path(current_webpacker_instance.manifest.lookup!(name))
174
+ path_to_asset(current_webpacker_instance.manifest.lookup!(name))
175
175
  end
176
176
  end