webpacker 3.6.0 → 4.0.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (106) hide show
  1. checksums.yaml +4 -4
  2. data/.node-version +1 -0
  3. data/.travis.yml +12 -4
  4. data/CHANGELOG.md +240 -28
  5. data/CONTRIBUTING.md +33 -0
  6. data/Gemfile +1 -1
  7. data/Gemfile.lock +78 -71
  8. data/MIT-LICENSE +1 -1
  9. data/README.md +75 -16
  10. data/docs/assets.md +7 -4
  11. data/docs/css.md +47 -14
  12. data/docs/deployment.md +11 -0
  13. data/docs/engines.md +155 -0
  14. data/docs/es6.md +5 -5
  15. data/docs/testing.md +1 -1
  16. data/docs/troubleshooting.md +4 -4
  17. data/docs/v4-upgrade.md +132 -0
  18. data/docs/webpack.md +56 -3
  19. data/docs/yarn.md +12 -1
  20. data/gemfiles/Gemfile-rails-edge +1 -1
  21. data/gemfiles/Gemfile-rails.4.2.x +2 -2
  22. data/gemfiles/Gemfile-rails.5.0.x +2 -2
  23. data/gemfiles/Gemfile-rails.5.1.x +2 -2
  24. data/gemfiles/Gemfile-rails.5.2.x +10 -0
  25. data/lib/install/bin/webpack +5 -1
  26. data/lib/install/bin/webpack-dev-server +5 -1
  27. data/lib/install/coffee.rb +2 -2
  28. data/lib/install/config/.browserslistrc +1 -0
  29. data/lib/install/config/babel.config.js +70 -0
  30. data/lib/install/config/postcss.config.js +12 -0
  31. data/lib/install/config/webpacker.yml +26 -0
  32. data/lib/install/elm.rb +2 -2
  33. data/lib/install/erb.rb +2 -2
  34. data/lib/install/examples/react/babel.config.js +83 -0
  35. data/lib/install/examples/stimulus/application.js +1 -6
  36. data/lib/install/examples/stimulus/controllers/index.js +9 -0
  37. data/lib/install/examples/typescript/tsconfig.json +4 -0
  38. data/lib/install/examples/vue/hello_vue.js +6 -4
  39. data/lib/install/javascript/packs/application.js +8 -0
  40. data/lib/install/loaders/typescript.js +8 -3
  41. data/lib/install/loaders/vue.js +1 -8
  42. data/lib/install/react.rb +6 -19
  43. data/lib/install/template.rb +29 -30
  44. data/lib/install/typescript.rb +4 -4
  45. data/lib/install/vue.rb +14 -5
  46. data/lib/tasks/installers.rake +4 -2
  47. data/lib/tasks/webpacker/binstubs.rake +3 -2
  48. data/lib/tasks/webpacker/compile.rake +10 -5
  49. data/lib/tasks/webpacker/install.rake +3 -2
  50. data/lib/tasks/webpacker/verify_install.rake +1 -4
  51. data/lib/tasks/webpacker/yarn_install.rake +1 -1
  52. data/lib/webpacker/commands.rb +0 -1
  53. data/lib/webpacker/compiler.rb +17 -13
  54. data/lib/webpacker/configuration.rb +13 -5
  55. data/lib/webpacker/dev_server.rb +7 -10
  56. data/lib/webpacker/dev_server_proxy.rb +13 -6
  57. data/lib/webpacker/dev_server_runner.rb +13 -6
  58. data/lib/webpacker/helper.rb +78 -20
  59. data/lib/webpacker/manifest.rb +64 -21
  60. data/lib/webpacker/railtie.rb +16 -7
  61. data/lib/webpacker/runner.rb +3 -3
  62. data/lib/webpacker/version.rb +1 -1
  63. data/lib/webpacker/webpack_runner.rb +14 -3
  64. data/package.json +46 -34
  65. data/package/__tests__/config.js +37 -3
  66. data/package/__tests__/dev_server.js +15 -0
  67. data/package/__tests__/production.js +2 -2
  68. data/package/__tests__/staging.js +3 -3
  69. data/package/__tests__/test.js +2 -1
  70. data/package/config.js +21 -9
  71. data/package/config_types/config_list.js +5 -6
  72. data/package/dev_server.js +3 -1
  73. data/package/environments/__tests__/base.js +7 -5
  74. data/package/environments/base.js +84 -31
  75. data/package/environments/development.js +6 -2
  76. data/package/environments/production.js +46 -36
  77. data/package/rules/babel.js +10 -4
  78. data/package/rules/file.js +8 -3
  79. data/package/rules/index.js +7 -2
  80. data/package/rules/node_modules.js +23 -0
  81. data/package/utils/__tests__/get_style_rule.js +20 -0
  82. data/package/utils/deep_merge.js +5 -6
  83. data/package/utils/get_style_rule.js +29 -42
  84. data/package/utils/helpers.js +18 -6
  85. data/package/utils/objectify.js +1 -2
  86. data/test/compiler_test.rb +15 -3
  87. data/test/configuration_test.rb +9 -0
  88. data/test/dev_server_runner_test.rb +51 -0
  89. data/test/helper_test.rb +48 -5
  90. data/test/manifest_test.rb +14 -0
  91. data/test/rake_tasks_test.rb +34 -0
  92. data/test/test_app/config.ru +5 -0
  93. data/test/test_app/config/application.rb +1 -0
  94. data/test/test_app/config/webpack/development.js +0 -0
  95. data/test/test_app/config/webpacker.yml +20 -0
  96. data/test/test_app/config/webpacker_public_root.yml +19 -0
  97. data/test/test_app/package.json +13 -0
  98. data/test/test_app/public/packs/manifest.json +22 -1
  99. data/test/test_app/yarn.lock +11 -0
  100. data/test/test_helper.rb +1 -3
  101. data/test/webpack_runner_test.rb +51 -0
  102. data/yarn.lock +4077 -2816
  103. metadata +28 -6
  104. data/lib/install/config/.babelrc +0 -18
  105. data/lib/install/config/.postcssrc.yml +0 -3
  106. data/lib/install/examples/react/.babelrc +0 -6
@@ -4,7 +4,7 @@
4
4
  # "/packs/calendar-1016838bab065ae1e314.css".
5
5
  #
6
6
  # When the configuration is set to on-demand compilation, with the `compile: true` option in
7
- # the webpacker.yml file, any lookups will be preceeded by a compilation if one is needed.
7
+ # the webpacker.yml file, any lookups will be preceded by a compilation if one is needed.
8
8
  class Webpacker::Manifest
9
9
  class MissingEntryError < StandardError; end
10
10
 
@@ -18,13 +18,35 @@ class Webpacker::Manifest
18
18
  @data = load
19
19
  end
20
20
 
21
- def lookup(name)
21
+ def lookup_pack_with_chunks(name, pack_type = {})
22
22
  compile if compiling?
23
- find name
23
+
24
+ manifest_pack_type = manifest_type(pack_type[:type])
25
+ manifest_pack_name = manifest_name(name, manifest_pack_type)
26
+ find("entrypoints")[manifest_pack_name][manifest_pack_type]
27
+ rescue NoMethodError
28
+ nil
29
+ end
30
+
31
+ def lookup_pack_with_chunks!(name, pack_type = {})
32
+ lookup_pack_with_chunks(name, pack_type) || handle_missing_entry(name)
33
+ end
34
+
35
+ # Computes the relative path for a given Webpacker asset using manifest.json.
36
+ # If no asset is found, returns nil.
37
+ #
38
+ # Example:
39
+ #
40
+ # Webpacker.manifest.lookup('calendar.js') # => "/packs/calendar-1016838bab065ae1e122.js"
41
+ def lookup(name, pack_type = {})
42
+ compile if compiling?
43
+
44
+ find(full_pack_name(name, pack_type[:type]))
24
45
  end
25
46
 
26
- def lookup!(name)
27
- lookup(name) || handle_missing_entry(name)
47
+ # Like lookup, except that if no asset is found, raises a Webpacker::Manifest::MissingEntryError.
48
+ def lookup!(name, pack_type = {})
49
+ lookup(name, pack_type) || handle_missing_entry(name)
28
50
  end
29
51
 
30
52
  private
@@ -36,14 +58,51 @@ class Webpacker::Manifest
36
58
  Webpacker.logger.tagged("Webpacker") { compiler.compile }
37
59
  end
38
60
 
61
+ def data
62
+ if config.cache_manifest?
63
+ @data ||= load
64
+ else
65
+ refresh
66
+ end
67
+ end
68
+
39
69
  def find(name)
40
70
  data[name.to_s].presence
41
71
  end
42
72
 
73
+ def full_pack_name(name, pack_type)
74
+ return name unless File.extname(name.to_s).empty?
75
+ "#{name}.#{manifest_type(pack_type)}"
76
+ end
77
+
43
78
  def handle_missing_entry(name)
44
79
  raise Webpacker::Manifest::MissingEntryError, missing_file_from_manifest_error(name)
45
80
  end
46
81
 
82
+ def load
83
+ if config.public_manifest_path.exist?
84
+ JSON.parse config.public_manifest_path.read
85
+ else
86
+ {}
87
+ end
88
+ end
89
+
90
+ # The `manifest_name` method strips of the file extension of the name, because in the
91
+ # manifest hash the entrypoints are defined by their pack name without the extension.
92
+ # When the user provides a name with a file extension, we want to try to strip it off.
93
+ def manifest_name(name, pack_type)
94
+ return name if File.extname(name.to_s).empty?
95
+ File.basename(name, pack_type)
96
+ end
97
+
98
+ def manifest_type(pack_type)
99
+ case pack_type
100
+ when :javascript then "js"
101
+ when :stylesheet then "css"
102
+ else pack_type.to_s
103
+ end
104
+ end
105
+
47
106
  def missing_file_from_manifest_error(bundle_name)
48
107
  <<-MSG
49
108
  Webpacker can't find #{bundle_name} in #{config.public_manifest_path}. Possible causes:
@@ -56,20 +115,4 @@ Your manifest contains:
56
115
  #{JSON.pretty_generate(@data)}
57
116
  MSG
58
117
  end
59
-
60
- def data
61
- if config.cache_manifest?
62
- @data ||= load
63
- else
64
- refresh
65
- end
66
- end
67
-
68
- def load
69
- if config.public_manifest_path.exist?
70
- JSON.parse config.public_manifest_path.read
71
- else
72
- {}
73
- end
74
- end
75
118
  end
@@ -6,7 +6,12 @@ require "webpacker/dev_server_proxy"
6
6
  class Webpacker::Engine < ::Rails::Engine
7
7
  # Allows Webpacker config values to be set via Rails env config files
8
8
  config.webpacker = ActiveSupport::OrderedOptions.new
9
- config.webpacker.check_yarn_integrity = false
9
+
10
+ initializer "webpacker.set_configs" do |app|
11
+ if app.config.webpacker.key?(:check_yarn_integrity)
12
+ Webpacker.config.check_yarn_integrity = app.config.webpacker.check_yarn_integrity
13
+ end
14
+ end
10
15
 
11
16
  # ================================
12
17
  # Check Yarn Integrity Initializer
@@ -24,18 +29,18 @@ class Webpacker::Engine < ::Rails::Engine
24
29
  # - edit config/environments/production.rb
25
30
  # - add `config.webpacker.check_yarn_integrity = true`
26
31
  initializer "webpacker.yarn_check" do |app|
27
- if File.exist?("yarn.lock") && app.config.webpacker.check_yarn_integrity
28
- output = `yarn check --integrity 2>&1`
32
+ if File.exist?("yarn.lock") && Webpacker.config.config_path.exist? && Webpacker.config.check_yarn_integrity?
33
+ output = `yarn check --integrity && yarn check --verify-tree 2>&1`
29
34
 
30
35
  unless $?.success?
31
36
  $stderr.puts "\n\n"
32
37
  $stderr.puts "========================================"
33
38
  $stderr.puts " Your Yarn packages are out of date!"
34
- $stderr.puts " Please run `yarn install` to update."
39
+ $stderr.puts " Please run `yarn install --check-files` to update."
35
40
  $stderr.puts "========================================"
36
41
  $stderr.puts "\n\n"
37
- $stderr.puts "To disable this check, please add `config.webpacker.check_yarn_integrity = false`"
38
- $stderr.puts "to your Rails development config file (config/environments/development.rb)."
42
+ $stderr.puts "To disable this check, please change `check_yarn_integrity`"
43
+ $stderr.puts "to `false` in your webpacker config file (config/webpacker.yml)."
39
44
  $stderr.puts "\n\n"
40
45
  $stderr.puts output
41
46
  $stderr.puts "\n\n"
@@ -77,7 +82,11 @@ class Webpacker::Engine < ::Rails::Engine
77
82
  initializer "webpacker.bootstrap" do
78
83
  if defined?(Rails::Server) || defined?(Rails::Console)
79
84
  Webpacker.bootstrap
80
- Spring.after_fork { Webpacker.bootstrap } if defined?(Spring)
85
+ if defined?(Spring)
86
+ require "spring/watcher"
87
+ Spring.after_fork { Webpacker.bootstrap }
88
+ Spring.watch(Webpacker.config.config_path)
89
+ end
81
90
  end
82
91
  end
83
92
  end
@@ -9,9 +9,9 @@ module Webpacker
9
9
  def initialize(argv)
10
10
  @argv = argv
11
11
 
12
- @app_path = File.expand_path(".", Dir.pwd)
13
- @node_modules_path = File.join(@app_path, "node_modules")
14
- @webpack_config = File.join(@app_path, "config/webpack/#{ENV["NODE_ENV"]}.js")
12
+ @app_path = File.expand_path(".", Dir.pwd)
13
+ @node_modules_bin_path = ENV["WEBPACKER_NODE_MODULES_BIN_PATH"] || `yarn bin`.chomp
14
+ @webpack_config = File.join(@app_path, "config/webpack/#{ENV["NODE_ENV"]}.js")
15
15
 
16
16
  unless File.exist?(@webpack_config)
17
17
  $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 = "3.6.0".freeze
3
+ VERSION = "4.0.2".freeze
4
4
  end
@@ -4,12 +4,23 @@ require "webpacker/runner"
4
4
  module Webpacker
5
5
  class WebpackRunner < Webpacker::Runner
6
6
  def run
7
- env = { "NODE_PATH" => @node_modules_path.shellescape }
8
- cmd = [ "#{@node_modules_path}/.bin/webpack", "--config", @webpack_config ] + @argv
7
+ env = Webpacker::Compiler.env
8
+
9
+ cmd = if node_modules_bin_exist?
10
+ ["#{@node_modules_bin_path}/webpack"]
11
+ else
12
+ ["yarn", "webpack"]
13
+ end
14
+ cmd += ["--config", @webpack_config] + @argv
9
15
 
10
16
  Dir.chdir(@app_path) do
11
- exec env, *cmd
17
+ Kernel.exec env, *cmd
12
18
  end
13
19
  end
20
+
21
+ private
22
+ def node_modules_bin_exist?
23
+ File.exist?("#{@node_modules_bin_path}/webpack")
24
+ end
14
25
  end
15
26
  end
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rails/webpacker",
3
- "version": "3.6.0",
3
+ "version": "4.0.2",
4
4
  "description": "Use webpack to manage app-like JavaScript modules in Rails",
5
5
  "main": "package/index.js",
6
6
  "files": [
@@ -8,43 +8,55 @@
8
8
  "lib/install/config/webpacker.yml"
9
9
  ],
10
10
  "engines": {
11
- "node": ">=6.0.0",
12
- "yarn": ">=0.25.2"
11
+ "node": ">=6.14.4",
12
+ "yarn": ">=1.0.0"
13
13
  },
14
14
  "dependencies": {
15
- "babel-core": "^6.26.3",
16
- "babel-loader": "^7.1.5",
17
- "babel-plugin-syntax-dynamic-import": "^6.18.0",
18
- "babel-plugin-transform-class-properties": "^6.24.1",
19
- "babel-plugin-transform-object-rest-spread": "^6.26.0",
20
- "babel-polyfill": "^6.26.0",
21
- "babel-preset-env": "^1.7.0",
22
- "case-sensitive-paths-webpack-plugin": "^2.1.2",
23
- "compression-webpack-plugin": "^1.1.11",
24
- "css-loader": "^0.28.11",
25
- "extract-text-webpack-plugin": "^3.0.2",
26
- "file-loader": "^1.1.11",
27
- "glob": "^7.1.2",
28
- "js-yaml": "^3.12.0",
29
- "node-sass": "^4.9.2",
30
- "optimize-css-assets-webpack-plugin": "^3.2.0",
15
+ "@babel/core": "^7.3.4",
16
+ "@babel/plugin-proposal-class-properties": "^7.3.4",
17
+ "@babel/plugin-proposal-object-rest-spread": "^7.3.4",
18
+ "@babel/plugin-syntax-dynamic-import": "^7.2.0",
19
+ "@babel/plugin-transform-destructuring": "^7.3.2",
20
+ "@babel/plugin-transform-regenerator": "^7.3.4",
21
+ "@babel/plugin-transform-runtime": "^7.3.4",
22
+ "@babel/polyfill": "^7.2.5",
23
+ "@babel/preset-env": "^7.3.4",
24
+ "@babel/runtime": "^7.3.4",
25
+ "babel-loader": "^8.0.5",
26
+ "babel-plugin-dynamic-import-node": "^2.2.0",
27
+ "babel-plugin-macros": "^2.5.0",
28
+ "case-sensitive-paths-webpack-plugin": "^2.2.0",
29
+ "compression-webpack-plugin": "^2.0.0",
30
+ "css-loader": "^2.1.0",
31
+ "file-loader": "^3.0.1",
32
+ "flatted": "^2.0.0",
33
+ "glob": "^7.1.3",
34
+ "js-yaml": "^3.12.2",
35
+ "mini-css-extract-plugin": "^0.5.0",
36
+ "node-sass": "^4.11.0",
37
+ "optimize-css-assets-webpack-plugin": "^5.0.1",
31
38
  "path-complete-extname": "^1.0.0",
32
- "postcss-cssnext": "^3.1.0",
33
- "postcss-import": "^11.1.0",
34
- "postcss-loader": "^2.1.5",
35
- "sass-loader": "^6.0.7",
36
- "style-loader": "^0.21.0",
37
- "uglifyjs-webpack-plugin": "^1.2.7",
38
- "webpack": "^3.12.0",
39
- "webpack-manifest-plugin": "^1.3.2"
39
+ "pnp-webpack-plugin": "^1.3.1",
40
+ "postcss-flexbugs-fixes": "^4.1.0",
41
+ "postcss-import": "^12.0.1",
42
+ "postcss-loader": "^3.0.0",
43
+ "postcss-preset-env": "^6.6.0",
44
+ "postcss-safe-parser": "^4.0.1",
45
+ "sass-loader": "^7.1.0",
46
+ "style-loader": "^0.23.1",
47
+ "terser-webpack-plugin": "^1.2.3",
48
+ "webpack": "^4.29.6",
49
+ "webpack-assets-manifest": "^3.1.1",
50
+ "webpack-cli": "^3.2.3",
51
+ "webpack-sources": "^1.3.0"
40
52
  },
41
53
  "devDependencies": {
42
- "eslint": "^4.19.1",
43
- "eslint-config-airbnb": "^16.1.0",
44
- "eslint-plugin-import": "^2.11.0",
45
- "eslint-plugin-jsx-a11y": "^6.0.3",
46
- "eslint-plugin-react": "^7.7.0",
47
- "jest": "^23.3.0"
54
+ "eslint": "^5.15.0",
55
+ "eslint-config-airbnb": "^17.1.0",
56
+ "eslint-plugin-import": "^2.16.0",
57
+ "eslint-plugin-jsx-a11y": "^6.2.1",
58
+ "eslint-plugin-react": "^7.12.4",
59
+ "jest": "^24.1.0"
48
60
  },
49
61
  "jest": {
50
62
  "testRegex": "(/__tests__/.*|(\\.|/))\\.jsx?$",
@@ -54,7 +66,7 @@
54
66
  },
55
67
  "scripts": {
56
68
  "test": "jest",
57
- "lint": "eslint {package,lib}/"
69
+ "lint": "eslint package/"
58
70
  },
59
71
  "repository": {
60
72
  "type": "git",
@@ -1,18 +1,17 @@
1
1
  /* global test expect, describe */
2
2
 
3
- const { chdirCwd, chdirTestApp } = require('../utils/helpers')
3
+ const { chdirCwd, chdirTestApp, resetEnv } = require('../utils/helpers')
4
4
 
5
5
  chdirTestApp()
6
6
 
7
7
  const config = require('../config')
8
8
 
9
9
  describe('Config', () => {
10
- beforeEach(() => jest.resetModules())
10
+ beforeEach(() => jest.resetModules() && resetEnv())
11
11
  afterAll(chdirCwd)
12
12
 
13
13
  test('public path', () => {
14
14
  process.env.RAILS_ENV = 'development'
15
- delete process.env.RAILS_RELATIVE_URL_ROOT
16
15
  const config = require('../config')
17
16
  expect(config.publicPath).toEqual('/packs/')
18
17
  })
@@ -25,8 +24,31 @@ describe('Config', () => {
25
24
  expect(config.publicPath).toEqual('/foo/packs/')
26
25
  })
27
26
 
27
+ test('public path with relative root without slash', () => {
28
+ process.env.RAILS_ENV = 'development'
29
+ process.env.RAILS_RELATIVE_URL_ROOT = 'foo'
30
+ const config = require('../config')
31
+ expect(config.publicPath).toEqual('/foo/packs/')
32
+ })
33
+
34
+ test('public path with asset host and relative root', () => {
35
+ process.env.RAILS_ENV = 'development'
36
+ process.env.RAILS_RELATIVE_URL_ROOT = '/foo/'
37
+ process.env.WEBPACKER_ASSET_HOST = 'http://foo.com/'
38
+ const config = require('../config')
39
+ expect(config.publicPath).toEqual('http://foo.com/foo/packs/')
40
+ })
41
+
42
+ test('public path with asset host', () => {
43
+ process.env.RAILS_ENV = 'development'
44
+ process.env.WEBPACKER_ASSET_HOST = 'http://foo.com/'
45
+ const config = require('../config')
46
+ expect(config.publicPath).toEqual('http://foo.com/packs/')
47
+ })
48
+
28
49
  test('should return extensions as listed in app config', () => {
29
50
  expect(config.extensions).toEqual([
51
+ '.mjs',
30
52
  '.js',
31
53
  '.sass',
32
54
  '.scss',
@@ -41,4 +63,16 @@ describe('Config', () => {
41
63
  '.jpg'
42
64
  ])
43
65
  })
66
+
67
+ test('should return static assets extensions as listed in app config', () => {
68
+ expect(config.static_assets_extensions).toEqual([
69
+ '.jpg',
70
+ '.jpeg',
71
+ '.png',
72
+ '.gif',
73
+ '.tiff',
74
+ '.ico',
75
+ '.svg',
76
+ ])
77
+ })
44
78
  })
@@ -20,6 +20,21 @@ describe('DevServer', () => {
20
20
  expect(devServer.port).toEqual('5000')
21
21
  })
22
22
 
23
+ test('with custom env prefix', () => {
24
+ const config = require('../config')
25
+ config.dev_server.env_prefix = 'TEST_WEBPACKER_DEV_SERVER'
26
+
27
+ process.env.NODE_ENV = 'development'
28
+ process.env.RAILS_ENV = 'development'
29
+ process.env.TEST_WEBPACKER_DEV_SERVER_HOST = '0.0.0.0'
30
+ process.env.TEST_WEBPACKER_DEV_SERVER_PORT = 5000
31
+
32
+ const devServer = require('../dev_server')
33
+ expect(devServer).toBeDefined()
34
+ expect(devServer.host).toEqual('0.0.0.0')
35
+ expect(devServer.port).toEqual('5000')
36
+ })
37
+
23
38
  test('with NODE_ENV and RAILS_ENV set to production', () => {
24
39
  process.env.RAILS_ENV = 'production'
25
40
  process.env.NODE_ENV = 'production'
@@ -17,11 +17,11 @@ describe('Production environment', () => {
17
17
 
18
18
  const { environment } = require('../index')
19
19
  const config = environment.toWebpackConfig()
20
-
20
+
21
21
  expect(config.output.path).toEqual(resolve('public', 'packs'))
22
22
  expect(config.output.publicPath).toEqual('/packs/')
23
23
  expect(config).toMatchObject({
24
- devtool: 'nosources-source-map',
24
+ devtool: 'source-map',
25
25
  stats: 'normal'
26
26
  })
27
27
  })
@@ -11,17 +11,17 @@ describe('Custom environment', () => {
11
11
  describe('toWebpackConfig', () => {
12
12
  beforeEach(() => jest.resetModules())
13
13
 
14
- test('should use staging config and production environment', () => {
14
+ test('should use staging config and default production environment', () => {
15
15
  process.env.RAILS_ENV = 'staging'
16
16
  delete process.env.NODE_ENV
17
17
 
18
18
  const { environment } = require('../index')
19
19
  const config = environment.toWebpackConfig()
20
-
20
+
21
21
  expect(config.output.path).toEqual(resolve('public', 'packs-staging'))
22
22
  expect(config.output.publicPath).toEqual('/packs-staging/')
23
23
  expect(config).toMatchObject({
24
- devtool: 'nosources-source-map',
24
+ devtool: 'source-map',
25
25
  stats: 'normal'
26
26
  })
27
27
  })