vite_rails 1.0.4 → 1.0.9

Sign up to get free protection for your applications and to get access to all the features.
Files changed (51) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +26 -1
  3. data/CONTRIBUTING.md +0 -1
  4. data/README.md +27 -65
  5. data/lib/install/javascript/entrypoints/application.js +8 -4
  6. data/lib/install/template.rb +1 -1
  7. data/lib/tasks/vite/build.rake +2 -6
  8. data/lib/tasks/vite/clean.rake +1 -3
  9. data/lib/tasks/vite/info.rake +0 -1
  10. data/lib/tasks/vite/verify_install.rake +3 -3
  11. data/lib/vite_rails.rb +19 -25
  12. data/lib/vite_rails/builder.rb +11 -4
  13. data/lib/vite_rails/commands.rb +50 -10
  14. data/lib/vite_rails/config.rb +35 -23
  15. data/lib/vite_rails/dev_server_proxy.rb +27 -16
  16. data/lib/vite_rails/helper.rb +36 -8
  17. data/lib/vite_rails/manifest.rb +20 -15
  18. data/lib/vite_rails/runner.rb +2 -5
  19. data/lib/vite_rails/version.rb +1 -1
  20. data/package.json +8 -20
  21. data/package/default.vite.json +1 -1
  22. data/test/builder_test.rb +27 -22
  23. data/test/commands_test.rb +67 -0
  24. data/test/configuration_test.rb +88 -46
  25. data/test/dev_server_proxy_test.rb +101 -0
  26. data/test/dev_server_test.rb +0 -30
  27. data/test/engine_rake_tasks_test.rb +55 -17
  28. data/test/helper_test.rb +37 -105
  29. data/test/manifest_test.rb +33 -29
  30. data/test/mode_test.rb +6 -11
  31. data/test/mounted_app/test/dummy/config/vite.json +5 -11
  32. data/test/mounted_app/test/dummy/package.json +2 -1
  33. data/test/mounted_app/test/dummy/yarn.lock +208 -0
  34. data/test/rake_tasks_test.rb +5 -19
  35. data/test/runner_test.rb +31 -0
  36. data/test/test_app/app/frontend/entrypoints/application.js +2 -0
  37. data/test/test_app/config/vite.json +0 -2
  38. data/test/test_app/config/vite_additional_paths.json +5 -0
  39. data/test/test_app/config/vite_public_dir.json +5 -0
  40. data/test/test_app/public/vite-production/manifest.json +22 -0
  41. data/test/test_helper.rb +48 -14
  42. metadata +21 -23
  43. data/test/command_test.rb +0 -35
  44. data/test/dev_server_runner_test.rb +0 -83
  45. data/test/test_app/app/javascript/entrypoints/application.js +0 -10
  46. data/test/test_app/app/javascript/entrypoints/multi_entry.css +0 -4
  47. data/test/test_app/app/javascript/entrypoints/multi_entry.js +0 -4
  48. data/test/test_app/config/vite_public_root.yml +0 -20
  49. data/test/test_app/public/vite/manifest.json +0 -36
  50. data/test/vite_runner_test.rb +0 -59
  51. data/test/webpacker_test.rb +0 -15
@@ -1,10 +0,0 @@
1
- /* eslint no-console:0 */
2
- // This file is automatically compiled by Vite, along with any other files
3
- // present in this directory. You're encouraged to place your actual application logic in
4
- // a relevant structure within app/javascript and only use these pack files to reference
5
- // that code so it'll be compiled.
6
- //
7
- // To reference this file, add <%= javascript_pack_tag 'application' %> to the appropriate
8
- // layout file, like app/views/layouts/application.html.erb
9
-
10
- console.log('Hello World from ViteRails')
@@ -1,4 +0,0 @@
1
- /*
2
- * Dummy file #1 for Multi File Entry points: https://vite.js.org/guides/entry-advanced/
3
- * This file must be named the same
4
- */
@@ -1,4 +0,0 @@
1
- /*
2
- * Dummy file #2 for Multi File Entry points: https://vite.js.org/guides/entry-advanced/
3
- * This file must be named the same
4
- */
@@ -1,20 +0,0 @@
1
- {
2
- "development": {
3
- "autoBuild": true,
4
- "port": "3535",
5
- "https": true,
6
- "publicDir": "../public"
7
- },
8
- "test": {
9
- "autoBuild": true,
10
- "publicOutputDir": "vite-test"
11
- },
12
- "production": {
13
- "autoBuild": false,
14
- "publicOutputDir": "vite-production"
15
- },
16
- "staging": {
17
- "autoBuild": false,
18
- "publicOutputDir": "vite-staging"
19
- }
20
- }
@@ -1,36 +0,0 @@
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
- "media/images/image.jpg": "/packs/media/images/image-c38deda30895059837cf.jpg",
9
- "media/images/image-2x.jpg": "/packs/media/images/image-2x-7cca48e6cae66ec07b8e.jpg",
10
- "media/images/nested/image.jpg": "/packs/media/images/nested/image-c38deda30895059837cf.jpg",
11
- "media/images/mb-icon.png": "/packs/media/images/mb-icon-c38deda30895059837cf.png",
12
- "media/images/nested/mb-icon.png": "/packs/media/images/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
- "hello_stimulus": {
28
- "assets": {
29
- "css": [
30
- "/packs/1-c20632e7baf2c81200d3.chunk.css",
31
- "/packs/hello_stimulus-k344a6d59eef8632c9d1.chunk.css"
32
- ]
33
- }
34
- }
35
- }
36
- }
@@ -1,59 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require 'test_helper'
4
-
5
- class ViteRunnerTest < ViteRails::Test
6
- def setup
7
- @original_node_env, ENV['NODE_ENV'] = ENV['NODE_ENV'], 'development'
8
- @original_rails_env, ENV['RAILS_ENV'] = ENV['RAILS_ENV'], 'development'
9
- end
10
-
11
- def teardown
12
- ENV['NODE_ENV'] = @original_node_env
13
- ENV['RAILS_ENV'] = @original_rails_env
14
- end
15
-
16
- def test_run_cmd_via_node_modules
17
- cmd = ["#{ test_app_path }/node_modules/.bin/vite", 'build', '--mode', 'development']
18
-
19
- verify_command(cmd, use_node_modules: true)
20
- end
21
-
22
- def test_run_cmd_via_yarn
23
- cmd = ['yarn', 'vite', 'build', '--mode', 'development']
24
-
25
- verify_command(cmd, use_node_modules: false)
26
- end
27
-
28
- def test_run_cmd_argv
29
- cmd = ["#{ test_app_path }/node_modules/.bin/vite", 'build', '--mode', 'development', '--emptyOutDir']
30
-
31
- verify_command(cmd, argv: ['--emptyOutDir'])
32
- end
33
-
34
- private
35
-
36
- def test_app_path
37
- File.expand_path('test_app', __dir__)
38
- end
39
-
40
- def verify_command(cmd, use_node_modules: true, argv: [])
41
- cwd = Dir.pwd
42
- Dir.chdir(test_app_path)
43
-
44
- klass = ViteRails::ViteRunner
45
- instance = klass.new(argv)
46
- mock = Minitest::Mock.new
47
- mock.expect(:call, nil, [ViteRails::Compiler.env, *cmd])
48
-
49
- klass.stub(:new, instance) do
50
- instance.stub(:executable_exists?, use_node_modules) do
51
- Kernel.stub(:exec, mock) { klass.run(argv) }
52
- end
53
- end
54
-
55
- mock.verify
56
- ensure
57
- Dir.chdir(cwd)
58
- end
59
- end
@@ -1,15 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require 'test_helper'
4
-
5
- class ViteRailsTest < ViteRails::Test
6
- def test_config_params
7
- assert_equal Rails.env, ViteRails.config.mode
8
- assert_equal ViteRails.instance.root_path, ViteRails.config.root_path
9
- assert_equal ViteRails.instance.config_path, ViteRails.config.config_path
10
-
11
- with_rails_env('test') do
12
- assert_equal 'test', ViteRails.config.env
13
- end
14
- end
15
- end