vite_rails 1.0.8 → 2.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (71) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +27 -1
  3. data/CONTRIBUTING.md +0 -1
  4. data/README.md +57 -32
  5. data/lib/tasks/vite.rake +17 -0
  6. data/lib/vite_rails.rb +5 -93
  7. data/lib/vite_rails/config.rb +11 -100
  8. data/lib/vite_rails/engine.rb +7 -11
  9. data/lib/vite_rails/installation.rb +47 -0
  10. data/lib/vite_rails/tag_helpers.rb +61 -0
  11. data/lib/vite_rails/version.rb +2 -2
  12. data/{lib/install/config/vite.json → templates/config/rails-vite.json} +1 -0
  13. data/{lib/install/javascript → templates}/entrypoints/application.js +0 -0
  14. metadata +25 -129
  15. data/lib/install/bin/vite +0 -17
  16. data/lib/install/binstubs.rb +0 -6
  17. data/lib/install/config/vite.config.ts +0 -11
  18. data/lib/install/template.rb +0 -40
  19. data/lib/tasks/vite/binstubs.rake +0 -12
  20. data/lib/tasks/vite/build.rake +0 -33
  21. data/lib/tasks/vite/clean.rake +0 -25
  22. data/lib/tasks/vite/clobber.rake +0 -20
  23. data/lib/tasks/vite/info.rake +0 -20
  24. data/lib/tasks/vite/install.rake +0 -12
  25. data/lib/tasks/vite/install_dependencies.rake +0 -20
  26. data/lib/tasks/vite/verify_install.rake +0 -23
  27. data/lib/vite_rails/builder.rb +0 -113
  28. data/lib/vite_rails/commands.rb +0 -68
  29. data/lib/vite_rails/dev_server.rb +0 -23
  30. data/lib/vite_rails/dev_server_proxy.rb +0 -49
  31. data/lib/vite_rails/helper.rb +0 -67
  32. data/lib/vite_rails/manifest.rb +0 -138
  33. data/lib/vite_rails/runner.rb +0 -56
  34. data/package.json +0 -16
  35. data/package/default.vite.json +0 -15
  36. data/test/builder_test.rb +0 -72
  37. data/test/command_test.rb +0 -35
  38. data/test/configuration_test.rb +0 -80
  39. data/test/dev_server_runner_test.rb +0 -83
  40. data/test/dev_server_test.rb +0 -39
  41. data/test/engine_rake_tasks_test.rb +0 -42
  42. data/test/helper_test.rb +0 -138
  43. data/test/manifest_test.rb +0 -75
  44. data/test/mode_test.rb +0 -21
  45. data/test/mounted_app/Rakefile +0 -6
  46. data/test/mounted_app/test/dummy/Rakefile +0 -5
  47. data/test/mounted_app/test/dummy/bin/rails +0 -5
  48. data/test/mounted_app/test/dummy/bin/rake +0 -5
  49. data/test/mounted_app/test/dummy/config.ru +0 -7
  50. data/test/mounted_app/test/dummy/config/application.rb +0 -12
  51. data/test/mounted_app/test/dummy/config/environment.rb +0 -5
  52. data/test/mounted_app/test/dummy/config/vite.json +0 -20
  53. data/test/mounted_app/test/dummy/package.json +0 -7
  54. data/test/rake_tasks_test.rb +0 -74
  55. data/test/test_app/Rakefile +0 -5
  56. data/test/test_app/app/javascript/entrypoints/application.js +0 -2
  57. data/test/test_app/app/javascript/entrypoints/multi_entry.css +0 -4
  58. data/test/test_app/app/javascript/entrypoints/multi_entry.js +0 -4
  59. data/test/test_app/bin/vite +0 -17
  60. data/test/test_app/config.ru +0 -7
  61. data/test/test_app/config/application.rb +0 -13
  62. data/test/test_app/config/environment.rb +0 -6
  63. data/test/test_app/config/vite.json +0 -20
  64. data/test/test_app/config/vite_public_root.yml +0 -20
  65. data/test/test_app/package.json +0 -13
  66. data/test/test_app/public/vite/manifest.json +0 -36
  67. data/test/test_app/some.config.js +0 -0
  68. data/test/test_app/yarn.lock +0 -11
  69. data/test/test_helper.rb +0 -34
  70. data/test/vite_runner_test.rb +0 -59
  71. data/test/webpacker_test.rb +0 -15
@@ -1,5 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require_relative 'config/application'
4
-
5
- Rails.application.load_tasks
@@ -1,2 +0,0 @@
1
- /* eslint no-console:0 */
2
- 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,17 +0,0 @@
1
- #!/usr/bin/env ruby
2
- # frozen_string_literal: true
3
-
4
- ENV['RAILS_ENV'] ||= ENV['RACK_ENV'] || 'development'
5
- ENV['NODE_ENV'] ||= ENV['RAILS_ENV'] == 'development' ? 'development' : 'production'
6
-
7
- require 'pathname'
8
- ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../Gemfile', Pathname.new(__FILE__).realpath)
9
-
10
- require 'bundler/setup'
11
-
12
- require 'vite_rails'
13
-
14
- APP_ROOT = File.expand_path('..', __dir__)
15
- Dir.chdir(APP_ROOT) do
16
- ViteRails.run(ARGV)
17
- end
@@ -1,7 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- # This file allows the `Rails.root` to be correctly determined.
4
-
5
- require_relative 'config/environment'
6
-
7
- run Rails.application
@@ -1,13 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require 'action_controller/railtie'
4
- require 'action_view/railtie'
5
- require 'vite_rails'
6
-
7
- module TestApp
8
- class Application < ::Rails::Application
9
- config.secret_key_base = 'abcdef'
10
- config.eager_load = true
11
- config.active_support.test_order = :sorted
12
- end
13
- end
@@ -1,6 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require_relative 'application'
4
-
5
- Rails.backtrace_cleaner.remove_silencers!
6
- Rails.application.initialize!
@@ -1,20 +0,0 @@
1
- {
2
- "development": {
3
- "autoBuild": true,
4
- "port": "3535",
5
- "https": true,
6
- "publicOutputDir": "vite-development"
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,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,13 +0,0 @@
1
- {
2
- "name": "test_app",
3
- "version": "1.0.0",
4
- "main": "index.js",
5
- "license": "MIT",
6
- "private": true,
7
- "dependencies": {
8
- "left-pad": "^1.2.0"
9
- },
10
- "devDependencies": {
11
- "right-pad": "^1.0.1"
12
- }
13
- }
@@ -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
- }
File without changes
@@ -1,11 +0,0 @@
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 DELETED
@@ -1,34 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require 'minitest/autorun'
4
- require 'rails'
5
- require 'rails/test_help'
6
- require 'byebug'
7
-
8
- require_relative 'test_app/config/environment'
9
-
10
- Rails.env = 'production'
11
-
12
- ViteRails.instance = ::ViteRails.new
13
-
14
- class ViteRails::Test < Minitest::Test
15
- private
16
-
17
- def reloaded_config
18
- ViteRails.instance.instance_variable_set(:@config, nil)
19
- ViteRails.instance.instance_variable_set(:@dev_server, nil)
20
- ViteRails.env = {}
21
- ViteRails.config
22
- ViteRails.dev_server
23
- end
24
-
25
- def with_rails_env(env)
26
- original = Rails.env
27
- Rails.env = ActiveSupport::StringInquirer.new(env)
28
- reloaded_config
29
- yield
30
- ensure
31
- Rails.env = ActiveSupport::StringInquirer.new(original)
32
- reloaded_config
33
- end
34
- end
@@ -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