shakapacker 6.0.0.rc.6
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.eslintignore +4 -0
- data/.eslintrc.js +14 -0
- data/.github/ISSUE_TEMPLATE/bug_report.md +20 -0
- data/.github/ISSUE_TEMPLATE/feature-request.md +18 -0
- data/.github/workflows/jest.yml +30 -0
- data/.github/workflows/js-lint.yml +31 -0
- data/.github/workflows/rubocop.yml +39 -0
- data/.github/workflows/ruby.yml +48 -0
- data/.gitignore +13 -0
- data/.node-version +1 -0
- data/.rubocop.yml +229 -0
- data/CHANGELOG.md +32 -0
- data/CONTRIBUTING.md +62 -0
- data/Gemfile +13 -0
- data/Gemfile.lock +183 -0
- data/MIT-LICENSE +20 -0
- data/README.md +666 -0
- data/Rakefile +11 -0
- data/config/README.md +3 -0
- data/config/webpacker.yml +1 -0
- data/docs/customizing_babel_config.md +59 -0
- data/docs/deployment.md +116 -0
- data/docs/developing_webpacker.md +29 -0
- data/docs/troubleshooting.md +212 -0
- data/docs/v6_upgrade.md +158 -0
- data/gemfiles/Gemfile-rails-edge +12 -0
- data/gemfiles/Gemfile-rails.5.2.x +9 -0
- data/gemfiles/Gemfile-rails.6.0.x +9 -0
- data/gemfiles/Gemfile-rails.6.1.x +12 -0
- data/lib/install/application.js +15 -0
- data/lib/install/bin/webpacker +15 -0
- data/lib/install/bin/webpacker-dev-server +18 -0
- data/lib/install/bin/yarn +18 -0
- data/lib/install/binstubs.rb +4 -0
- data/lib/install/config/webpack/webpack.config.js +5 -0
- data/lib/install/config/webpacker.yml +64 -0
- data/lib/install/package.json +15 -0
- data/lib/install/template.rb +100 -0
- data/lib/shakapacker/utils/git_utils.rb +23 -0
- data/lib/shakapacker/utils/version_syntax_converter.rb +24 -0
- data/lib/tasks/webpacker/binstubs.rake +15 -0
- data/lib/tasks/webpacker/check_binstubs.rake +12 -0
- data/lib/tasks/webpacker/check_node.rake +31 -0
- data/lib/tasks/webpacker/check_yarn.rake +33 -0
- data/lib/tasks/webpacker/clean.rake +25 -0
- data/lib/tasks/webpacker/clobber.rake +20 -0
- data/lib/tasks/webpacker/compile.rake +45 -0
- data/lib/tasks/webpacker/info.rake +21 -0
- data/lib/tasks/webpacker/install.rake +17 -0
- data/lib/tasks/webpacker/verify_config.rake +14 -0
- data/lib/tasks/webpacker/verify_install.rake +4 -0
- data/lib/tasks/webpacker/yarn_install.rake +18 -0
- data/lib/tasks/webpacker.rake +19 -0
- data/lib/tasks/yarn.rake +38 -0
- data/lib/webpacker/commands.rb +79 -0
- data/lib/webpacker/compiler.rb +130 -0
- data/lib/webpacker/configuration.rb +111 -0
- data/lib/webpacker/dev_server.rb +72 -0
- data/lib/webpacker/dev_server_proxy.rb +33 -0
- data/lib/webpacker/dev_server_runner.rb +96 -0
- data/lib/webpacker/env.rb +43 -0
- data/lib/webpacker/helper.rb +161 -0
- data/lib/webpacker/instance.rb +41 -0
- data/lib/webpacker/manifest.rb +120 -0
- data/lib/webpacker/railtie.rb +63 -0
- data/lib/webpacker/runner.rb +23 -0
- data/lib/webpacker/version.rb +4 -0
- data/lib/webpacker/webpack_runner.rb +58 -0
- data/lib/webpacker.rb +46 -0
- data/package/__tests__/config.js +34 -0
- data/package/__tests__/dev_server.js +45 -0
- data/package/__tests__/development.js +35 -0
- data/package/__tests__/env.js +58 -0
- data/package/__tests__/index.js +9 -0
- data/package/__tests__/production.js +29 -0
- data/package/__tests__/staging.js +30 -0
- data/package/__tests__/test.js +25 -0
- data/package/babel/preset.js +41 -0
- data/package/config.js +32 -0
- data/package/configPath.js +3 -0
- data/package/dev_server.js +20 -0
- data/package/env.js +27 -0
- data/package/environments/__tests__/base.js +69 -0
- data/package/environments/base.js +116 -0
- data/package/environments/development.js +55 -0
- data/package/environments/production.js +79 -0
- data/package/environments/test.js +3 -0
- data/package/index.js +33 -0
- data/package/inliningCss.js +7 -0
- data/package/rules/babel.js +30 -0
- data/package/rules/coffee.js +6 -0
- data/package/rules/css.js +3 -0
- data/package/rules/erb.js +15 -0
- data/package/rules/file.js +23 -0
- data/package/rules/index.js +18 -0
- data/package/rules/less.js +22 -0
- data/package/rules/raw.js +5 -0
- data/package/rules/sass.js +16 -0
- data/package/rules/stylus.js +26 -0
- data/package/utils/get_style_rule.js +37 -0
- data/package/utils/helpers.js +51 -0
- data/package.json +71 -0
- data/rakelib/release.rake +57 -0
- data/test/command_test.rb +109 -0
- data/test/compiler_test.rb +68 -0
- data/test/configuration_test.rb +78 -0
- data/test/dev_server_runner_test.rb +81 -0
- data/test/dev_server_test.rb +47 -0
- data/test/engine_rake_tasks_test.rb +39 -0
- data/test/env_test.rb +23 -0
- data/test/helper_test.rb +159 -0
- data/test/manifest_test.rb +89 -0
- data/test/mounted_app/Rakefile +4 -0
- data/test/mounted_app/test/dummy/Rakefile +3 -0
- data/test/mounted_app/test/dummy/bin/rails +3 -0
- data/test/mounted_app/test/dummy/bin/rake +3 -0
- data/test/mounted_app/test/dummy/config/application.rb +10 -0
- data/test/mounted_app/test/dummy/config/environment.rb +3 -0
- data/test/mounted_app/test/dummy/config/webpacker.yml +75 -0
- data/test/mounted_app/test/dummy/config.ru +5 -0
- data/test/mounted_app/test/dummy/package.json +7 -0
- data/test/rake_tasks_test.rb +71 -0
- data/test/test_app/Rakefile +3 -0
- data/test/test_app/app/packs/entrypoints/application.js +10 -0
- data/test/test_app/app/packs/entrypoints/multi_entry.css +4 -0
- data/test/test_app/app/packs/entrypoints/multi_entry.js +4 -0
- data/test/test_app/bin/webpacker +14 -0
- data/test/test_app/bin/webpacker-dev-server +14 -0
- data/test/test_app/config/application.rb +11 -0
- data/test/test_app/config/environment.rb +4 -0
- data/test/test_app/config/initializers/inspect_autoload_paths.rb +1 -0
- data/test/test_app/config/webpack/webpack.config.js +0 -0
- data/test/test_app/config/webpacker.yml +77 -0
- data/test/test_app/config/webpacker_other_location.yml +79 -0
- data/test/test_app/config/webpacker_public_root.yml +18 -0
- data/test/test_app/config.ru +5 -0
- data/test/test_app/package.json +13 -0
- data/test/test_app/public/packs/manifest.json +50 -0
- data/test/test_app/some.config.js +0 -0
- data/test/test_app/yarn.lock +11 -0
- data/test/test_helper.rb +33 -0
- data/test/webpack_runner_test.rb +57 -0
- data/test/webpacker_test.rb +34 -0
- data/webpacker.gemspec +31 -0
- data/yarn.lock +4029 -0
- metadata +331 -0
@@ -0,0 +1,14 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
ENV["RAILS_ENV"] ||= "development"
|
4
|
+
ENV["NODE_ENV"] ||= ENV["RAILS_ENV"]
|
5
|
+
|
6
|
+
require "pathname"
|
7
|
+
ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../../Gemfile",
|
8
|
+
Pathname.new(__FILE__).realpath)
|
9
|
+
|
10
|
+
require "bundler/setup"
|
11
|
+
|
12
|
+
require "webpacker"
|
13
|
+
require "webpacker/webpack_runner"
|
14
|
+
Webpacker::WebpackRunner.run(ARGV)
|
@@ -0,0 +1,14 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
ENV["RAILS_ENV"] ||= "development"
|
4
|
+
ENV["NODE_ENV"] ||= ENV["RAILS_ENV"]
|
5
|
+
|
6
|
+
require "pathname"
|
7
|
+
ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../../Gemfile",
|
8
|
+
Pathname.new(__FILE__).realpath)
|
9
|
+
|
10
|
+
require "bundler/setup"
|
11
|
+
|
12
|
+
require "webpacker"
|
13
|
+
require "webpacker/dev_server_runner"
|
14
|
+
Webpacker::DevServerRunner.run(ARGV)
|
@@ -0,0 +1,11 @@
|
|
1
|
+
require "action_controller/railtie"
|
2
|
+
require "action_view/railtie"
|
3
|
+
require "webpacker"
|
4
|
+
|
5
|
+
module TestApp
|
6
|
+
class Application < ::Rails::Application
|
7
|
+
config.secret_key_base = "abcdef"
|
8
|
+
config.eager_load = true
|
9
|
+
config.active_support.test_order = :sorted
|
10
|
+
end
|
11
|
+
end
|
@@ -0,0 +1 @@
|
|
1
|
+
$test_app_autoload_paths_in_initializer = ActiveSupport::Dependencies.autoload_paths
|
File without changes
|
@@ -0,0 +1,77 @@
|
|
1
|
+
# Note: You must restart bin/webpacker-dev-server for changes to take effect
|
2
|
+
|
3
|
+
default: &default
|
4
|
+
source_path: app/packs
|
5
|
+
source_entry_path: entrypoints
|
6
|
+
public_root_path: public
|
7
|
+
public_output_path: packs
|
8
|
+
cache_path: tmp/webpacker
|
9
|
+
webpack_compile_output: false
|
10
|
+
|
11
|
+
# Additional paths webpack should look up modules
|
12
|
+
# ['app/assets', 'engine/foo/app/assets']
|
13
|
+
additional_paths:
|
14
|
+
- app/assets
|
15
|
+
- /etc/yarn
|
16
|
+
- some.config.js
|
17
|
+
- app/elm
|
18
|
+
|
19
|
+
# Reload manifest.json on all requests so we reload latest compiled packs
|
20
|
+
cache_manifest: false
|
21
|
+
|
22
|
+
static_assets_extensions:
|
23
|
+
- .jpg
|
24
|
+
- .jpeg
|
25
|
+
- .png
|
26
|
+
- .gif
|
27
|
+
- .tiff
|
28
|
+
- .ico
|
29
|
+
- .svg
|
30
|
+
|
31
|
+
extensions:
|
32
|
+
- .mjs
|
33
|
+
- .js
|
34
|
+
|
35
|
+
development:
|
36
|
+
<<: *default
|
37
|
+
compile: true
|
38
|
+
|
39
|
+
# Reference: https://webpack.js.org/configuration/dev-server/
|
40
|
+
dev_server:
|
41
|
+
https: false
|
42
|
+
host: localhost
|
43
|
+
port: 3035
|
44
|
+
public: localhost:3035
|
45
|
+
hmr: false
|
46
|
+
overlay: true
|
47
|
+
disable_host_check: true
|
48
|
+
use_local_ip: false
|
49
|
+
pretty: false
|
50
|
+
|
51
|
+
test:
|
52
|
+
<<: *default
|
53
|
+
compile: true
|
54
|
+
|
55
|
+
# Compile test packs to a separate directory
|
56
|
+
public_output_path: packs-test
|
57
|
+
|
58
|
+
production:
|
59
|
+
<<: *default
|
60
|
+
|
61
|
+
# Production depends on precompilation of packs prior to booting for performance.
|
62
|
+
compile: false
|
63
|
+
|
64
|
+
# Cache manifest.json for performance
|
65
|
+
cache_manifest: true
|
66
|
+
|
67
|
+
staging:
|
68
|
+
<<: *default
|
69
|
+
|
70
|
+
# Production depends on precompilation of packs prior to booting for performance.
|
71
|
+
compile: false
|
72
|
+
|
73
|
+
# Cache manifest.json for performance
|
74
|
+
cache_manifest: true
|
75
|
+
|
76
|
+
# Compile staging packs to a separate directory
|
77
|
+
public_output_path: packs-staging
|
@@ -0,0 +1,79 @@
|
|
1
|
+
# Note: You must restart bin/webpacker-dev-server for changes to take effect
|
2
|
+
|
3
|
+
default: &default
|
4
|
+
source_path: app/packs
|
5
|
+
source_entry_path: entrypoints
|
6
|
+
public_root_path: public
|
7
|
+
public_output_path: packs
|
8
|
+
cache_path: tmp/cache/webpacker
|
9
|
+
webpack_compile_output: false
|
10
|
+
|
11
|
+
# Additional paths webpack should look up modules
|
12
|
+
# ['app/assets', 'engine/foo/app/assets']
|
13
|
+
additional_paths:
|
14
|
+
- app/assets
|
15
|
+
- /etc/yarn
|
16
|
+
- some.config.js
|
17
|
+
- app/elm
|
18
|
+
|
19
|
+
# Reload manifest.json on all requests so we reload latest compiled packs
|
20
|
+
cache_manifest: false
|
21
|
+
|
22
|
+
static_assets_extensions:
|
23
|
+
- .jpg
|
24
|
+
- .jpeg
|
25
|
+
- .png
|
26
|
+
- .gif
|
27
|
+
- .tiff
|
28
|
+
- .ico
|
29
|
+
- .svg
|
30
|
+
|
31
|
+
extensions:
|
32
|
+
- .mjs
|
33
|
+
- .js
|
34
|
+
|
35
|
+
development:
|
36
|
+
<<: *default
|
37
|
+
compile: true
|
38
|
+
|
39
|
+
# Reference: https://webpack.js.org/configuration/dev-server/
|
40
|
+
dev_server:
|
41
|
+
https: false
|
42
|
+
host: localhost
|
43
|
+
port: 3035
|
44
|
+
public: localhost:3035
|
45
|
+
hmr: false
|
46
|
+
# Inline should be set to true if using HMR
|
47
|
+
inline: true
|
48
|
+
overlay: true
|
49
|
+
disable_host_check: true
|
50
|
+
use_local_ip: false
|
51
|
+
pretty: false
|
52
|
+
|
53
|
+
test:
|
54
|
+
<<: *default
|
55
|
+
compile: true
|
56
|
+
|
57
|
+
# Compile test packs to a separate directory
|
58
|
+
public_output_path: packs-test
|
59
|
+
|
60
|
+
production:
|
61
|
+
<<: *default
|
62
|
+
|
63
|
+
# Production depends on precompilation of packs prior to booting for performance.
|
64
|
+
compile: false
|
65
|
+
|
66
|
+
# Cache manifest.json for performance
|
67
|
+
cache_manifest: true
|
68
|
+
|
69
|
+
staging:
|
70
|
+
<<: *default
|
71
|
+
|
72
|
+
# Production depends on precompilation of packs prior to booting for performance.
|
73
|
+
compile: false
|
74
|
+
|
75
|
+
# Cache manifest.json for performance
|
76
|
+
cache_manifest: true
|
77
|
+
|
78
|
+
# Compile staging packs to a separate directory
|
79
|
+
public_output_path: packs-staging
|
@@ -0,0 +1,18 @@
|
|
1
|
+
# Note: You must restart bin/webpacker-dev-server for changes to take effect
|
2
|
+
|
3
|
+
default: &default
|
4
|
+
public_root_path: ../public
|
5
|
+
|
6
|
+
development:
|
7
|
+
<<: *default
|
8
|
+
compile: true
|
9
|
+
|
10
|
+
test:
|
11
|
+
<<: *default
|
12
|
+
compile: true
|
13
|
+
public_output_path: packs-test
|
14
|
+
|
15
|
+
production:
|
16
|
+
<<: *default
|
17
|
+
compile: false
|
18
|
+
cache_manifest: true
|
@@ -0,0 +1,50 @@
|
|
1
|
+
{
|
2
|
+
"bootstrap.css": "/packs/bootstrap-c38deda30895059837cf.css",
|
3
|
+
"application.css": "/packs/application-dd6b1cd38bfa093df600.css",
|
4
|
+
"bootstrap.js": "/packs/bootstrap-300631c4f0e0f9c865bc.js",
|
5
|
+
"application.js": "/packs/application-k344a6d59eef8632c9d1.js",
|
6
|
+
"application.png": "/packs/application-k344a6d59eef8632c9d1.png",
|
7
|
+
"fonts/fa-regular-400.woff2": "/packs/fonts/fa-regular-400-944fb546bd7018b07190a32244f67dc9.woff2",
|
8
|
+
"static/image.jpg": "/packs/static/image-c38deda30895059837cf.jpg",
|
9
|
+
"static/image-2x.jpg": "/packs/static/image-2x-7cca48e6cae66ec07b8e.jpg",
|
10
|
+
"static/nested/image.jpg": "/packs/static/nested/image-c38deda30895059837cf.jpg",
|
11
|
+
"static/mb-icon.png": "/packs/static/mb-icon-c38deda30895059837cf.png",
|
12
|
+
"static/nested/mb-icon.png": "/packs/static/nested/mb-icon-c38deda30895059837cf.png",
|
13
|
+
"entrypoints": {
|
14
|
+
"application": {
|
15
|
+
"assets": {
|
16
|
+
"js": [
|
17
|
+
"/packs/vendors~application~bootstrap-c20632e7baf2c81200d3.chunk.js",
|
18
|
+
"/packs/vendors~application-e55f2aae30c07fb6d82a.chunk.js",
|
19
|
+
"/packs/application-k344a6d59eef8632c9d1.js"
|
20
|
+
],
|
21
|
+
"css": [
|
22
|
+
"/packs/1-c20632e7baf2c81200d3.chunk.css",
|
23
|
+
"/packs/application-k344a6d59eef8632c9d1.chunk.css"
|
24
|
+
]
|
25
|
+
}
|
26
|
+
},
|
27
|
+
"bootstrap": {
|
28
|
+
"assets": {
|
29
|
+
"js": [
|
30
|
+
"/packs/bootstrap-300631c4f0e0f9c865bc.js"
|
31
|
+
]
|
32
|
+
}
|
33
|
+
},
|
34
|
+
"hello_stimulus": {
|
35
|
+
"assets": {
|
36
|
+
"css": [
|
37
|
+
"/packs/1-c20632e7baf2c81200d3.chunk.css",
|
38
|
+
"/packs/hello_stimulus-k344a6d59eef8632c9d1.chunk.css"
|
39
|
+
]
|
40
|
+
}
|
41
|
+
},
|
42
|
+
"print/application": {
|
43
|
+
"assets": {
|
44
|
+
"css": [
|
45
|
+
"/packs/print/application-983b6c164a47f7ed49cd.css"
|
46
|
+
]
|
47
|
+
}
|
48
|
+
}
|
49
|
+
}
|
50
|
+
}
|
File without changes
|
@@ -0,0 +1,11 @@
|
|
1
|
+
# THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY.
|
2
|
+
# yarn lockfile v1
|
3
|
+
|
4
|
+
|
5
|
+
left-pad@^1.2.0:
|
6
|
+
version "1.2.0"
|
7
|
+
resolved "https://registry.yarnpkg.com/left-pad/-/left-pad-1.2.0.tgz#d30a73c6b8201d8f7d8e7956ba9616087a68e0ee"
|
8
|
+
|
9
|
+
right-pad@^1.0.1:
|
10
|
+
version "1.0.1"
|
11
|
+
resolved "https://registry.yarnpkg.com/right-pad/-/right-pad-1.0.1.tgz#8ca08c2cbb5b55e74dafa96bf7fd1a27d568c8d0"
|
data/test/test_helper.rb
ADDED
@@ -0,0 +1,33 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
require "minitest/autorun"
|
3
|
+
require "rails"
|
4
|
+
require "rails/test_help"
|
5
|
+
require "byebug"
|
6
|
+
|
7
|
+
require_relative "test_app/config/environment"
|
8
|
+
|
9
|
+
Rails.env = "production"
|
10
|
+
|
11
|
+
Webpacker.instance = ::Webpacker::Instance.new
|
12
|
+
|
13
|
+
class Webpacker::Test < Minitest::Test
|
14
|
+
private
|
15
|
+
def reloaded_config
|
16
|
+
Webpacker.instance.instance_variable_set(:@env, nil)
|
17
|
+
Webpacker.instance.instance_variable_set(:@config, nil)
|
18
|
+
Webpacker.instance.instance_variable_set(:@dev_server, nil)
|
19
|
+
Webpacker.env
|
20
|
+
Webpacker.config
|
21
|
+
Webpacker.dev_server
|
22
|
+
end
|
23
|
+
|
24
|
+
def with_rails_env(env)
|
25
|
+
original = Rails.env
|
26
|
+
Rails.env = ActiveSupport::StringInquirer.new(env)
|
27
|
+
reloaded_config
|
28
|
+
yield
|
29
|
+
ensure
|
30
|
+
Rails.env = ActiveSupport::StringInquirer.new(original)
|
31
|
+
reloaded_config
|
32
|
+
end
|
33
|
+
end
|
@@ -0,0 +1,57 @@
|
|
1
|
+
require "test_helper"
|
2
|
+
require "webpacker/webpack_runner"
|
3
|
+
|
4
|
+
class WebpackRunnerTest < Webpacker::Test
|
5
|
+
def setup
|
6
|
+
@original_node_env, ENV["NODE_ENV"] = ENV["NODE_ENV"], "development"
|
7
|
+
@original_rails_env, ENV["RAILS_ENV"] = ENV["RAILS_ENV"], "development"
|
8
|
+
end
|
9
|
+
|
10
|
+
def teardown
|
11
|
+
ENV["NODE_ENV"] = @original_node_env
|
12
|
+
ENV["RAILS_ENV"] = @original_rails_env
|
13
|
+
end
|
14
|
+
|
15
|
+
def test_run_cmd_via_node_modules
|
16
|
+
cmd = ["#{test_app_path}/node_modules/.bin/webpack", "--config", "#{test_app_path}/config/webpack/webpack.config.js"]
|
17
|
+
|
18
|
+
verify_command(cmd, use_node_modules: true)
|
19
|
+
end
|
20
|
+
|
21
|
+
def test_run_cmd_via_yarn
|
22
|
+
cmd = ["yarn", "webpack", "--config", "#{test_app_path}/config/webpack/webpack.config.js"]
|
23
|
+
|
24
|
+
verify_command(cmd, use_node_modules: false)
|
25
|
+
end
|
26
|
+
|
27
|
+
def test_run_cmd_argv
|
28
|
+
cmd = ["#{test_app_path}/node_modules/.bin/webpack", "--config", "#{test_app_path}/config/webpack/webpack.config.js", "--watch"]
|
29
|
+
|
30
|
+
verify_command(cmd, argv: ["--watch"])
|
31
|
+
end
|
32
|
+
|
33
|
+
private
|
34
|
+
def test_app_path
|
35
|
+
File.expand_path("test_app", __dir__)
|
36
|
+
end
|
37
|
+
|
38
|
+
def verify_command(cmd, use_node_modules: true, argv: [])
|
39
|
+
cwd = Dir.pwd
|
40
|
+
Dir.chdir(test_app_path)
|
41
|
+
|
42
|
+
klass = Webpacker::WebpackRunner
|
43
|
+
instance = klass.new(argv)
|
44
|
+
mock = Minitest::Mock.new
|
45
|
+
mock.expect(:call, nil, [Webpacker::Compiler.env, *cmd])
|
46
|
+
|
47
|
+
klass.stub(:new, instance) do
|
48
|
+
instance.stub(:node_modules_bin_exist?, use_node_modules) do
|
49
|
+
Kernel.stub(:exec, mock) { klass.run(argv) }
|
50
|
+
end
|
51
|
+
end
|
52
|
+
|
53
|
+
mock.verify
|
54
|
+
ensure
|
55
|
+
Dir.chdir(cwd)
|
56
|
+
end
|
57
|
+
end
|
@@ -0,0 +1,34 @@
|
|
1
|
+
require "test_helper"
|
2
|
+
|
3
|
+
class WebpackerTest < Webpacker::Test
|
4
|
+
def test_config_params
|
5
|
+
assert_equal Rails.env, Webpacker.config.env
|
6
|
+
assert_equal Webpacker.instance.root_path, Webpacker.config.root_path
|
7
|
+
assert_equal Webpacker.instance.config_path, Webpacker.config.config_path
|
8
|
+
|
9
|
+
with_rails_env("test") do
|
10
|
+
assert_equal "test", Webpacker.config.env
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
def test_inline_css_no_dev_server
|
15
|
+
assert !Webpacker.inlining_css?
|
16
|
+
end
|
17
|
+
|
18
|
+
def test_inline_css_with_hmr
|
19
|
+
dev_server = Webpacker::DevServer.new({})
|
20
|
+
def dev_server.host; "localhost"; end
|
21
|
+
def dev_server.port; "3035"; end
|
22
|
+
def dev_server.pretty?; false; end
|
23
|
+
def dev_server.https?; true; end
|
24
|
+
def dev_server.hmr?; true; end
|
25
|
+
def dev_server.running?; true; end
|
26
|
+
Webpacker.instance.stub(:dev_server, dev_server) do
|
27
|
+
assert Webpacker.inlining_css?
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
def test_app_autoload_paths_cleanup
|
32
|
+
assert_empty $test_app_autoload_paths_in_initializer
|
33
|
+
end
|
34
|
+
end
|
data/webpacker.gemspec
ADDED
@@ -0,0 +1,31 @@
|
|
1
|
+
$:.push File.expand_path("../lib", __FILE__)
|
2
|
+
require "webpacker/version"
|
3
|
+
|
4
|
+
Gem::Specification.new do |s|
|
5
|
+
s.name = "shakapacker"
|
6
|
+
s.version = Webpacker::VERSION
|
7
|
+
s.authors = [ "David Heinemeier Hansson", "Gaurav Tiwari", "Justin Gordon" ]
|
8
|
+
s.email = [ "david@basecamp.com", "gaurav@gauravtiwari.co.uk", "justin@shakacode.com" ]
|
9
|
+
s.summary = "Use webpack to manage app-like JavaScript modules in Rails"
|
10
|
+
s.homepage = "https://github.com/shakacode/shakapacker"
|
11
|
+
s.license = "MIT"
|
12
|
+
|
13
|
+
npm_version = Webpacker::VERSION.gsub(".rc", "-rc")
|
14
|
+
s.metadata = {
|
15
|
+
"source_code_uri" => "https://github.com/shakacode/shakapacker/tree/v#{npm_version}",
|
16
|
+
}
|
17
|
+
|
18
|
+
s.required_ruby_version = ">= 2.7.0"
|
19
|
+
|
20
|
+
s.add_dependency "activesupport", ">= 5.2"
|
21
|
+
s.add_dependency "railties", ">= 5.2"
|
22
|
+
s.add_dependency "rack-proxy", ">= 0.6.1"
|
23
|
+
s.add_dependency "semantic_range", ">= 2.3.0"
|
24
|
+
|
25
|
+
s.add_development_dependency "bundler", ">= 1.3.0"
|
26
|
+
s.add_development_dependency "rubocop"
|
27
|
+
s.add_development_dependency "rubocop-performance"
|
28
|
+
|
29
|
+
s.files = `git ls-files`.split("\n")
|
30
|
+
s.test_files = `git ls-files -- test/*`.split("\n")
|
31
|
+
end
|