webpacker 5.1.0 → 5.3.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (58) hide show
  1. checksums.yaml +4 -4
  2. data/.eslintrc.js +8 -8
  3. data/.github/workflows/jest.yml +38 -0
  4. data/.github/workflows/js-lint.yml +39 -0
  5. data/.github/workflows/rubocop.yml +39 -0
  6. data/.github/workflows/ruby.yml +66 -0
  7. data/.node-version +1 -1
  8. data/.rubocop.yml +113 -13
  9. data/CHANGELOG.md +27 -2
  10. data/Gemfile.lock +112 -103
  11. data/README.md +11 -19
  12. data/docs/css.md +58 -3
  13. data/docs/integrations.md +1 -1
  14. data/docs/target.md +22 -0
  15. data/docs/testing.md +1 -1
  16. data/docs/troubleshooting.md +3 -1
  17. data/docs/typescript.md +89 -8
  18. data/docs/webpack-dev-server.md +1 -1
  19. data/lib/install/config/babel.config.js +1 -3
  20. data/lib/install/config/webpacker.yml +1 -1
  21. data/lib/install/template.rb +9 -1
  22. data/lib/install/typescript.rb +2 -5
  23. data/lib/tasks/webpacker/check_node.rake +1 -1
  24. data/lib/tasks/webpacker/check_yarn.rake +2 -3
  25. data/lib/tasks/webpacker/yarn_install.rake +7 -1
  26. data/lib/webpacker/commands.rb +1 -1
  27. data/lib/webpacker/compiler.rb +7 -2
  28. data/lib/webpacker/configuration.rb +12 -4
  29. data/lib/webpacker/dev_server_runner.rb +2 -2
  30. data/lib/webpacker/helper.rb +29 -10
  31. data/lib/webpacker/runner.rb +1 -0
  32. data/lib/webpacker/version.rb +1 -1
  33. data/lib/webpacker/webpack_runner.rb +2 -2
  34. data/package.json +35 -35
  35. data/package/__tests__/config.js +12 -1
  36. data/package/__tests__/development.js +14 -1
  37. data/package/config.js +4 -1
  38. data/package/configPath.js +3 -0
  39. data/package/env.js +1 -2
  40. data/package/environments/__tests__/base.js +25 -8
  41. data/package/environments/base.js +5 -6
  42. data/package/environments/development.js +39 -33
  43. data/package/environments/production.js +1 -3
  44. data/package/rules/babel.js +11 -4
  45. data/package/rules/file.js +3 -2
  46. data/package/rules/node_modules.js +1 -3
  47. data/package/rules/sass.js +4 -1
  48. data/package/utils/helpers.js +1 -1
  49. data/test/compiler_test.rb +8 -3
  50. data/test/configuration_test.rb +8 -7
  51. data/test/dev_server_runner_test.rb +1 -1
  52. data/test/helper_test.rb +3 -0
  53. data/test/test_app/config/webpacker.yml +7 -1
  54. data/test/test_app/public/packs/manifest.json +1 -0
  55. data/test/webpack_runner_test.rb +1 -1
  56. data/webpacker.gemspec +1 -1
  57. data/yarn.lock +3290 -3588
  58. metadata +19 -13
@@ -3,19 +3,18 @@ namespace :webpacker do
3
3
  desc "Verifies if Yarn is installed"
4
4
  task :check_yarn do
5
5
  begin
6
- yarn_version = `yarn --version`
6
+ yarn_version = `yarn --version`.strip
7
7
  raise Errno::ENOENT if yarn_version.blank?
8
8
 
9
9
  pkg_path = Pathname.new("#{__dir__}/../../../package.json").realpath
10
10
  yarn_range = JSON.parse(pkg_path.read)["engines"]["yarn"]
11
11
  is_valid = SemanticRange.satisfies?(yarn_version, yarn_range) rescue false
12
- is_unsupported = SemanticRange.satisfies?(yarn_version, ">=2.0.0") rescue false
12
+ is_unsupported = SemanticRange.satisfies?(yarn_version, ">=3.0.0") rescue false
13
13
 
14
14
  unless is_valid
15
15
  $stderr.puts "Webpacker requires Yarn \"#{yarn_range}\" and you are using #{yarn_version}"
16
16
  if is_unsupported
17
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
18
  else
20
19
  $stderr.puts "Please upgrade Yarn https://yarnpkg.com/lang/en/docs/install/"
21
20
  end
@@ -5,6 +5,12 @@ namespace :webpacker do
5
5
  node_env = ENV.fetch("NODE_ENV") do
6
6
  valid_node_envs.include?(Rails.env) ? Rails.env : "production"
7
7
  end
8
- system({ "NODE_ENV" => node_env }, "yarn install --no-progress --frozen-lockfile")
8
+ yarn_flags =
9
+ if `yarn --version`.start_with?("1")
10
+ "--no-progress --frozen-lockfile"
11
+ else
12
+ "--immutable"
13
+ end
14
+ system({ "NODE_ENV" => node_env }, "yarn install #{yarn_flags}")
9
15
  end
10
16
  end
@@ -23,7 +23,7 @@ class Webpacker::Commands
23
23
  .each_with_index
24
24
  .drop_while do |(mtime, _), index|
25
25
  max_age = [0, Time.now - Time.at(mtime)].max
26
- max_age < age && index < count
26
+ max_age < age || index < count
27
27
  end
28
28
  .each do |(_, files), index|
29
29
  files.each do |file|
@@ -4,6 +4,8 @@ require "digest/sha1"
4
4
  class Webpacker::Compiler
5
5
  # Additional paths that test compiler needs to watch
6
6
  # Webpacker::Compiler.watched_paths << 'bower_components'
7
+ #
8
+ # Deprecated. Use additional_paths in the YAML configuration instead.
7
9
  cattr_accessor(:watched_paths) { [] }
8
10
 
9
11
  # Additional environment variables that the compiler is being run with
@@ -50,6 +52,8 @@ class Webpacker::Compiler
50
52
  end
51
53
 
52
54
  def watched_files_digest
55
+ warn "Webpacker::Compiler.watched_paths has been deprecated. Set additional_paths in webpacker.yml instead." unless watched_paths.empty?
56
+
53
57
  files = Dir[*default_watched_paths, *watched_paths].reject { |f| File.directory?(f) }
54
58
  file_ids = files.sort.map { |f| "#{File.basename(f)}/#{Digest::SHA1.file(f).hexdigest}" }
55
59
  Digest::SHA1.hexdigest(file_ids.join("/"))
@@ -86,7 +90,7 @@ class Webpacker::Compiler
86
90
 
87
91
  def default_watched_paths
88
92
  [
89
- *config.resolved_paths_globbed,
93
+ *config.additional_paths_globbed,
90
94
  config.source_path_globbed,
91
95
  "yarn.lock", "package.json",
92
96
  "config/webpack/**/*"
@@ -101,6 +105,7 @@ class Webpacker::Compiler
101
105
  return env unless defined?(ActionController::Base)
102
106
 
103
107
  env.merge("WEBPACKER_ASSET_HOST" => ENV.fetch("WEBPACKER_ASSET_HOST", ActionController::Base.helpers.compute_asset_host),
104
- "WEBPACKER_RELATIVE_URL_ROOT" => ENV.fetch("WEBPACKER_RELATIVE_URL_ROOT", ActionController::Base.relative_url_root))
108
+ "WEBPACKER_RELATIVE_URL_ROOT" => ENV.fetch("WEBPACKER_RELATIVE_URL_ROOT", ActionController::Base.relative_url_root),
109
+ "WEBPACKER_CONFIG" => webpacker.config_path.to_s)
105
110
  end
106
111
  end
@@ -27,12 +27,12 @@ class Webpacker::Configuration
27
27
  globbed_path_with_extensions(source_path.relative_path_from(root_path))
28
28
  end
29
29
 
30
- def resolved_paths
31
- fetch(:resolved_paths)
30
+ def additional_paths
31
+ fetch(:additional_paths) + resolved_paths
32
32
  end
33
33
 
34
- def resolved_paths_globbed
35
- resolved_paths.map { |p| globbed_path_with_extensions(p) }
34
+ def additional_paths_globbed
35
+ additional_paths.map { |p| globbed_path_with_extensions(p) }
36
36
  end
37
37
 
38
38
  def source_entry_path
@@ -76,6 +76,14 @@ class Webpacker::Configuration
76
76
  end
77
77
 
78
78
  private
79
+ def resolved_paths
80
+ paths = data.fetch(:resolved_paths, [])
81
+
82
+ warn "The resolved_paths option has been deprecated. Use additional_paths instead." unless paths.empty?
83
+
84
+ paths
85
+ end
86
+
79
87
  def fetch(key)
80
88
  data.fetch(key, defaults[key])
81
89
  end
@@ -45,6 +45,7 @@ module Webpacker
45
45
 
46
46
  def execute_cmd
47
47
  env = Webpacker::Compiler.env
48
+ env["WEBPACKER_CONFIG"] = @webpacker_config
48
49
 
49
50
  cmd = if node_modules_bin_exist?
50
51
  ["#{@node_modules_bin_path}/webpack-dev-server"]
@@ -52,9 +53,8 @@ module Webpacker
52
53
  ["yarn", "webpack-dev-server"]
53
54
  end
54
55
 
55
- if ARGV.include?("--debug")
56
+ if @argv.include?("--debug-webpacker")
56
57
  cmd = [ "node", "--inspect-brk"] + cmd
57
- ARGV.delete("--debug")
58
58
  end
59
59
 
60
60
  cmd += ["--config", @webpack_config]
@@ -46,7 +46,16 @@ module Webpacker::Helper
46
46
  #
47
47
  # <%= image_pack_tag 'application.png', size: '16x10', alt: 'Edit Entry' %>
48
48
  # <img alt='Edit Entry' src='/packs/application-k344a6d59eef8632c9d1.png' width='16' height='10' />
49
+ #
50
+ # <%= image_pack_tag 'picture.png', srcset: { 'picture-2x.png' => '2x' } %>
51
+ # <img srcset= "/packs/picture-2x-7cca48e6cae66ec07b8e.png 2x" src="/packs/picture-c38deda30895059837cf.png" >
49
52
  def image_pack_tag(name, **options)
53
+ if options[:srcset] && !options[:srcset].is_a?(String)
54
+ options[:srcset] = options[:srcset].map do |src_name, size|
55
+ "#{resolve_path_to_image(src_name)} #{size}"
56
+ end.join(", ")
57
+ end
58
+
50
59
  image_tag(resolve_path_to_image(name), options)
51
60
  end
52
61
 
@@ -61,7 +70,7 @@ module Webpacker::Helper
61
70
  end
62
71
 
63
72
  # 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
73
+ # in package/environments/base.js. By default, this list is auto-generated to match everything in
65
74
  # app/javascript/packs/*.js. In production mode, the digested reference is automatically looked up.
66
75
  #
67
76
  # Example:
@@ -73,10 +82,11 @@ module Webpacker::Helper
73
82
  end
74
83
 
75
84
  # 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.
85
+ # as compiled by webpack per the entries list in package/environments/base.js.
77
86
  # By default, this list is auto-generated to match everything in
78
87
  # app/javascript/packs/*.js and all the dependent chunks. In production mode, the digested reference is automatically looked up.
79
88
  # See: https://webpack.js.org/plugins/split-chunks-plugin/
89
+ #
80
90
  # Example:
81
91
  #
82
92
  # <%= javascript_packs_with_chunks_tag 'calendar', 'map', 'data-turbolinks-track': 'reload' %> # =>
@@ -85,11 +95,15 @@ module Webpacker::Helper
85
95
  # <script src="/packs/calendar-1016838bab065ae1e314.chunk.js" data-turbolinks-track="reload"></script>
86
96
  # <script src="/packs/map~runtime-16838bab065ae1e314.chunk.js" data-turbolinks-track="reload"></script>
87
97
  # <script src="/packs/map-16838bab065ae1e314.chunk.js" data-turbolinks-track="reload"></script>
98
+ #
88
99
  # DO:
89
- # <%= javascript_packs_with_chunks_tag 'calendar', 'map' %>
100
+ #
101
+ # <%= javascript_packs_with_chunks_tag 'calendar', 'map' %>
102
+ #
90
103
  # DON'T:
91
- # <%= javascript_packs_with_chunks_tag 'calendar' %>
92
- # <%= javascript_packs_with_chunks_tag 'map' %>
104
+ #
105
+ # <%= javascript_packs_with_chunks_tag 'calendar' %>
106
+ # <%= javascript_packs_with_chunks_tag 'map' %>
93
107
  def javascript_packs_with_chunks_tag(*names, **options)
94
108
  javascript_include_tag(*sources_from_manifest_entrypoints(names, type: :javascript), **options)
95
109
  end
@@ -97,6 +111,7 @@ module Webpacker::Helper
97
111
  # Creates a link tag, for preloading, that references a given Webpacker asset.
98
112
  # In production mode, the digested reference is automatically looked up.
99
113
  # See: https://developer.mozilla.org/en-US/docs/Web/HTML/Preloading_content
114
+ #
100
115
  # Example:
101
116
  #
102
117
  # <%= preload_pack_asset 'fonts/fa-regular-400.woff2' %> # =>
@@ -110,7 +125,7 @@ module Webpacker::Helper
110
125
  end
111
126
 
112
127
  # 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
128
+ # in package/environments/base.js. By default, this list is auto-generated to match everything in
114
129
  # app/javascript/packs/*.js. In production mode, the digested reference is automatically looked up.
115
130
  #
116
131
  # Note: If the development server is running and hot module replacement is active, this will return nothing.
@@ -132,7 +147,7 @@ module Webpacker::Helper
132
147
  end
133
148
 
134
149
  # 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.
150
+ # as compiled by webpack per the entries list in package/environments/base.js.
136
151
  # By default, this list is auto-generated to match everything in
137
152
  # app/javascript/packs/*.js and all the dependent chunks. In production mode, the digested reference is automatically looked up.
138
153
  # See: https://webpack.js.org/plugins/split-chunks-plugin/
@@ -143,11 +158,15 @@ module Webpacker::Helper
143
158
  # <link rel="stylesheet" media="screen" href="/packs/3-8c7ce31a.chunk.css" />
144
159
  # <link rel="stylesheet" media="screen" href="/packs/calendar-8c7ce31a.chunk.css" />
145
160
  # <link rel="stylesheet" media="screen" href="/packs/map-8c7ce31a.chunk.css" />
161
+ #
146
162
  # DO:
147
- # <%= stylesheet_packs_with_chunks_tag 'calendar', 'map' %>
163
+ #
164
+ # <%= stylesheet_packs_with_chunks_tag 'calendar', 'map' %>
165
+ #
148
166
  # DON'T:
149
- # <%= stylesheet_packs_with_chunks_tag 'calendar' %>
150
- # <%= stylesheet_packs_with_chunks_tag 'map' %>
167
+ #
168
+ # <%= stylesheet_packs_with_chunks_tag 'calendar' %>
169
+ # <%= stylesheet_packs_with_chunks_tag 'map' %>
151
170
  def stylesheet_packs_with_chunks_tag(*names, **options)
152
171
  if current_webpacker_instance.config.extract_css?
153
172
  stylesheet_link_tag(*sources_from_manifest_entrypoints(names, type: :stylesheet), **options)
@@ -12,6 +12,7 @@ module Webpacker
12
12
  @app_path = File.expand_path(".", Dir.pwd)
13
13
  @node_modules_bin_path = ENV["WEBPACKER_NODE_MODULES_BIN_PATH"] || `yarn bin`.chomp
14
14
  @webpack_config = File.join(@app_path, "config/webpack/#{ENV["NODE_ENV"]}.js")
15
+ @webpacker_config = File.join(@app_path, "config/webpacker.yml")
15
16
 
16
17
  unless File.exist?(@webpack_config)
17
18
  $stderr.puts "webpack config #{@webpack_config} not found, please run 'bundle exec rails webpacker:install' to install Webpacker with default configs or add the missing config file for your custom environment."
@@ -1,4 +1,4 @@
1
1
  module Webpacker
2
2
  # Change the version in package.json too, please!
3
- VERSION = "5.1.0".freeze
3
+ VERSION = "5.3.0".freeze
4
4
  end
@@ -5,6 +5,7 @@ module Webpacker
5
5
  class WebpackRunner < Webpacker::Runner
6
6
  def run
7
7
  env = Webpacker::Compiler.env
8
+ env["WEBPACKER_CONFIG"] = @webpacker_config
8
9
 
9
10
  cmd = if node_modules_bin_exist?
10
11
  ["#{@node_modules_bin_path}/webpack"]
@@ -12,9 +13,8 @@ module Webpacker
12
13
  ["yarn", "webpack"]
13
14
  end
14
15
 
15
- if ARGV.include?("--debug")
16
+ if @argv.include?("--debug-webpacker")
16
17
  cmd = [ "node", "--inspect-brk"] + cmd
17
- ARGV.delete("--debug")
18
18
  end
19
19
 
20
20
  cmd += ["--config", @webpack_config] + @argv
data/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rails/webpacker",
3
- "version": "5.1.0",
3
+ "version": "5.3.0",
4
4
  "description": "Use webpack to manage app-like JavaScript modules in Rails",
5
5
  "main": "package/index.js",
6
6
  "files": [
@@ -8,56 +8,56 @@
8
8
  "lib/install/config/webpacker.yml"
9
9
  ],
10
10
  "engines": {
11
- "node": ">=10.13.0",
12
- "yarn": ">=1 <2"
11
+ "node": ">=10.17.0",
12
+ "yarn": ">=1 <3"
13
13
  },
14
14
  "dependencies": {
15
- "@babel/core": "^7.9.0",
16
- "@babel/plugin-proposal-class-properties": "^7.8.3",
17
- "@babel/plugin-proposal-object-rest-spread": "^7.9.0",
15
+ "@babel/core": "^7.13.16",
16
+ "@babel/plugin-proposal-class-properties": "^7.13.0",
17
+ "@babel/plugin-proposal-object-rest-spread": "^7.13.8",
18
18
  "@babel/plugin-syntax-dynamic-import": "^7.8.3",
19
- "@babel/plugin-transform-destructuring": "^7.8.8",
20
- "@babel/plugin-transform-regenerator": "^7.8.7",
21
- "@babel/plugin-transform-runtime": "^7.9.0",
22
- "@babel/preset-env": "^7.9.0",
23
- "@babel/runtime": "^7.9.2",
24
- "babel-loader": "^8.1.0",
25
- "babel-plugin-dynamic-import-node": "^2.3.0",
19
+ "@babel/plugin-transform-destructuring": "^7.13.17",
20
+ "@babel/plugin-transform-regenerator": "^7.13.15",
21
+ "@babel/plugin-transform-runtime": "^7.13.15",
22
+ "@babel/preset-env": "^7.13.15",
23
+ "@babel/runtime": "^7.13.17",
24
+ "babel-loader": "^8.2.2",
25
+ "babel-plugin-dynamic-import-node": "^2.3.3",
26
26
  "babel-plugin-macros": "^2.8.0",
27
- "case-sensitive-paths-webpack-plugin": "^2.3.0",
28
- "compression-webpack-plugin": "^3.1.0",
29
- "core-js": "^3.6.4",
30
- "css-loader": "^3.4.2",
31
- "file-loader": "^6.0.0",
32
- "flatted": "^2.0.1",
27
+ "case-sensitive-paths-webpack-plugin": "^2.4.0",
28
+ "compression-webpack-plugin": "^4.0.1",
29
+ "core-js": "^3.11.0",
30
+ "css-loader": "^3.6.0",
31
+ "file-loader": "^6.2.0",
32
+ "flatted": "^3.1.1",
33
33
  "glob": "^7.1.6",
34
- "js-yaml": "^3.13.1",
34
+ "js-yaml": "^3.14.1",
35
35
  "mini-css-extract-plugin": "^0.9.0",
36
- "node-sass": "^4.13.1",
37
- "optimize-css-assets-webpack-plugin": "^5.0.3",
36
+ "optimize-css-assets-webpack-plugin": "^5.0.4",
38
37
  "path-complete-extname": "^1.0.0",
39
38
  "pnp-webpack-plugin": "^1.6.4",
40
- "postcss-flexbugs-fixes": "^4.2.0",
39
+ "postcss-flexbugs-fixes": "^4.2.1",
41
40
  "postcss-import": "^12.0.1",
42
41
  "postcss-loader": "^3.0.0",
43
42
  "postcss-preset-env": "^6.7.0",
44
43
  "postcss-safe-parser": "^4.0.2",
45
- "regenerator-runtime": "^0.13.5",
46
- "sass-loader": "^8.0.2",
47
- "style-loader": "^1.1.3",
48
- "terser-webpack-plugin": "^2.3.5",
49
- "webpack": "^4.42.1",
44
+ "regenerator-runtime": "^0.13.7",
45
+ "sass": "^1.32.11",
46
+ "sass-loader": "10.1.1",
47
+ "style-loader": "^1.3.0",
48
+ "terser-webpack-plugin": "^4.2.3",
49
+ "webpack": "^4.46.0",
50
50
  "webpack-assets-manifest": "^3.1.1",
51
- "webpack-cli": "^3.3.11",
51
+ "webpack-cli": "^3.3.12",
52
52
  "webpack-sources": "^1.4.3"
53
53
  },
54
54
  "devDependencies": {
55
- "eslint": "^6.8.0",
56
- "eslint-config-airbnb": "^18.1.0",
57
- "eslint-plugin-import": "^2.20.1",
58
- "eslint-plugin-jsx-a11y": "^6.2.3",
59
- "eslint-plugin-react": "^7.19.0",
60
- "jest": "^25.1.0"
55
+ "eslint": "^7.25.0",
56
+ "eslint-config-airbnb": "^18.2.1",
57
+ "eslint-plugin-import": "^2.22.1",
58
+ "eslint-plugin-jsx-a11y": "^6.4.1",
59
+ "eslint-plugin-react": "^7.23.2",
60
+ "jest": "^26.6.3"
61
61
  },
62
62
  "jest": {
63
63
  "testRegex": "(/__tests__/.*|(\\.|/))\\.jsx?$",
@@ -23,6 +23,16 @@ describe('Config', () => {
23
23
  expect(config.publicPath).toEqual('http://foo.com/packs/')
24
24
  })
25
25
 
26
+ test('should return additional paths as listed in app config, with resolved paths', () => {
27
+ expect(config.additional_paths).toEqual(
28
+ [
29
+ 'app/assets',
30
+ '/etc/yarn',
31
+ 'app/elm'
32
+ ]
33
+ )
34
+ })
35
+
26
36
  test('should return extensions as listed in app config', () => {
27
37
  expect(config.extensions).toEqual([
28
38
  '.mjs',
@@ -37,7 +47,8 @@ describe('Config', () => {
37
47
  '.svg',
38
48
  '.gif',
39
49
  '.jpeg',
40
- '.jpg'
50
+ '.jpg',
51
+ '.elm'
41
52
  ])
42
53
  })
43
54
 
@@ -11,9 +11,10 @@ describe('Development environment', () => {
11
11
  describe('toWebpackConfig', () => {
12
12
  beforeEach(() => jest.resetModules())
13
13
 
14
- test('should use development config and environment', () => {
14
+ test('should use development config and environment including devServer if WEBPACK_DEV_SERVER', () => {
15
15
  process.env.RAILS_ENV = 'development'
16
16
  process.env.NODE_ENV = 'development'
17
+ process.env.WEBPACK_DEV_SERVER = 'YES'
17
18
  const { environment } = require('../index')
18
19
 
19
20
  const config = environment.toWebpackConfig()
@@ -26,5 +27,17 @@ describe('Development environment', () => {
26
27
  }
27
28
  })
28
29
  })
30
+
31
+ test('should use development config and environment if WEBPACK_DEV_SERVER', () => {
32
+ process.env.RAILS_ENV = 'development'
33
+ process.env.NODE_ENV = 'development'
34
+ process.env.WEBPACK_DEV_SERVER = undefined
35
+ const { environment } = require('../index')
36
+
37
+ const config = environment.toWebpackConfig()
38
+ expect(config.output.path).toEqual(resolve('public', 'packs'))
39
+ expect(config.output.publicPath).toEqual('/packs/')
40
+ expect(config.devServer).toEqual(undefined)
41
+ })
29
42
  })
30
43
  })
data/package/config.js CHANGED
@@ -4,9 +4,9 @@ const { readFileSync } = require('fs')
4
4
  const deepMerge = require('./utils/deep_merge')
5
5
  const { isArray, ensureTrailingSlash } = require('./utils/helpers')
6
6
  const { railsEnv } = require('./env')
7
+ const configPath = require('./configPath')
7
8
 
8
9
  const defaultConfigPath = require.resolve('../lib/install/config/webpacker.yml')
9
- const configPath = resolve('config', 'webpacker.yml')
10
10
 
11
11
  const getDefaultConfig = () => {
12
12
  const defaultConfig = safeLoad(readFileSync(defaultConfigPath), 'utf8')
@@ -24,6 +24,9 @@ if (isArray(app.static_assets_extensions) && app.static_assets_extensions.length
24
24
  const config = deepMerge(defaults, app)
25
25
  config.outputPath = resolve(config.public_root_path, config.public_output_path)
26
26
 
27
+ // Merge resolved_paths into additional_paths for backwards-compat
28
+ config.additional_paths = config.additional_paths.concat(config.resolved_paths || [])
29
+
27
30
  // Ensure that the publicPath includes our asset host so dynamic imports
28
31
  // (code-splitting chunks and static assets) load from the CDN instead of a relative path.
29
32
  const getPublicPath = () => {