17 |
18 |
19 |
--------------------------------------------------------------------------------
/vite-plugin-rails/example/app/frontend/App.vue:
--------------------------------------------------------------------------------
1 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
26 |
--------------------------------------------------------------------------------
/vite-plugin-ruby/example/app/frontend/App.vue:
--------------------------------------------------------------------------------
1 |
12 |
13 |
21 |
22 |
23 |
24 |
25 |
26 |
--------------------------------------------------------------------------------
/docs/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "private": true,
3 | "scripts": {
4 | "dev": "vitepress dev --port 3005 --open",
5 | "build": "vitepress build",
6 | "preview": "vitepress serve --port 5050 --open",
7 | "now": "npm run build && npm run preview"
8 | },
9 | "dependencies": {
10 | "@mussi/vitepress-theme": "^1.0.2",
11 | "vite-plugin-windicss": "^1.8.3",
12 | "vitepress": "^0.22.3",
13 | "vue": "^3.2.31"
14 | },
15 | "pnpm": {
16 | "peerDependencyRules": {
17 | "ignoreMissing": [
18 | "@algolia/client-search",
19 | "react",
20 | "react-dom",
21 | "@types/react"
22 | ]
23 | }
24 | }
25 | }
26 |
--------------------------------------------------------------------------------
/test/file_operations_benchmark.rb:
--------------------------------------------------------------------------------
1 | # frozen_string_literal: true
2 |
3 | require "benchmark/ips"
4 | require "bundler/setup"
5 |
6 | Benchmark.ips do |x|
7 | x.config(time: 3, warmup: 1)
8 |
9 | dir = Pathname.new(__dir__).join("..")
10 |
11 | x.report("Pathname#file?") { dir.join("Gemfile").file? }
12 | x.report("Pathname#exist?") { dir.join("Gemfile").exist? }
13 | x.report("File.exist?") { File.exist?("#{dir}/Gemfile") }
14 | x.report("File.file?") { File.file?("#{dir}/Gemfile") }
15 | x.report("File.exist? w/join") { File.exist?(dir.join("Gemfile")) }
16 | x.report("File.file? w/join") { File.file?(dir.join("Gemfile")) }
17 |
18 | x.compare!
19 | end
20 |
--------------------------------------------------------------------------------
/vite_padrino/lib/vite_padrino.rb:
--------------------------------------------------------------------------------
1 | # frozen_string_literal: true
2 |
3 | require "vite_ruby"
4 | require "vite_padrino/version"
5 | require "vite_padrino/tag_helpers"
6 |
7 | module VitePadrino
8 | # Internal: Called when the Rack app is available.
9 | def self.registered(app)
10 | if RACK_ENV != "production" && ViteRuby.run_proxy?
11 | app.use(ViteRuby::DevServerProxy, ssl_verify_none: true)
12 | end
13 | ViteRuby.instance.logger = app.logger
14 | included(app)
15 | end
16 |
17 | # Internal: Called when the module is registered in the Padrino app.
18 | def self.included(base)
19 | base.send :include, VitePadrino::TagHelpers
20 | end
21 | end
22 |
--------------------------------------------------------------------------------
/examples/rails/Dockerfile:
--------------------------------------------------------------------------------
1 | FROM ruby:3.0 AS builder
2 |
3 | # Install nodejs in the ruby image
4 | RUN curl -sL https://deb.nodesource.com/setup_16.x | bash - && apt-get install -y nodejs
5 | RUN npm install -g yarn
6 |
7 | # Gems and packages will be cached in a separate image using a mounted volume.
8 | ENV BUNDLE_PATH /bundler_cache
9 | ENV YARN_CACHE_FOLDER /yarn_cache
10 | ENV BUNDLER_VERSION 2.3.22
11 |
12 | # Match the version of Bundler with that specified in Gemfile.lock
13 | RUN gem update --system \
14 | && gem install bundler -v $BUNDLER_VERSION
15 |
16 | # Set working directory inside the image home.
17 | ENV APP_PATH /app
18 | WORKDIR $APP_PATH
19 | ADD . $APP_PATH
20 |
--------------------------------------------------------------------------------
/examples/rails/tsconfig.json:
--------------------------------------------------------------------------------
1 | {
2 | "compilerOptions": {
3 | "baseUrl": ".",
4 | "module": "es2020",
5 | "target": "es2020",
6 | "moduleResolution": "node",
7 | "allowJs": true,
8 | "jsx": "preserve",
9 | "jsxFactory": "h",
10 | "jsxFragmentFactory": "Fragment",
11 | "strict": true,
12 | "declaration": true,
13 | "noUnusedLocals": true,
14 | "skipLibCheck": true,
15 | "esModuleInterop": true,
16 | "lib": ["ESNext", "DOM"],
17 | "paths": {
18 | "~/*": ["./app/frontend/*"],
19 | "@/*": ["./app/frontend/*"]
20 | },
21 | },
22 | "exclude": [
23 | "**/dist",
24 | "**/node_modules",
25 | "**/public"
26 | ]
27 | }
28 |
--------------------------------------------------------------------------------
/.github/ISSUE_TEMPLATE/feature_request.md:
--------------------------------------------------------------------------------
1 | ---
2 | name: Feature request
3 | about: Suggest an idea for this project
4 | title: ''
5 | labels: ''
6 | assignees: ''
7 |
8 | ---
9 |
10 | **Is your feature request related to a problem? Please describe.**
11 | A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]
12 |
13 | **Describe the solution you'd like**
14 | A clear and concise description of what you want to happen.
15 |
16 | **Describe alternatives you've considered**
17 | A clear and concise description of any alternative solutions or features you've considered.
18 |
19 | **Additional context**
20 | Add any other context or screenshots about the feature request here.
21 |
--------------------------------------------------------------------------------
/vite-plugin-ruby/example/app/frontend/ssr/ssr.ts:
--------------------------------------------------------------------------------
1 | import { createSSRApp, h } from 'vue'
2 | import { renderToString } from '@vue/server-renderer'
3 | import { createInertiaApp } from '@inertiajs/inertia-vue3'
4 | import createServer from '@inertiajs/server'
5 | import logo from '~/images/logo.svg'
6 | console.info({ logo })
7 |
8 | const pages = import.meta.glob('../pages/*.vue', { import: 'default', eager: true })
9 |
10 | createServer(page => createInertiaApp({
11 | page,
12 | render: renderToString,
13 | resolve: name => pages[`../Pages/${name}.vue`],
14 | setup ({ app, props, plugin }) {
15 | return createSSRApp({
16 | render: () => h(app, props),
17 | }).use(plugin)
18 | },
19 | }))
20 |
--------------------------------------------------------------------------------
/vite_ruby/lib/vite_ruby/cli/build.rb:
--------------------------------------------------------------------------------
1 | # frozen_string_literal: true
2 |
3 | class ViteRuby::CLI::Build < ViteRuby::CLI::Vite
4 | DEFAULT_ENV = CURRENT_ENV || "production"
5 |
6 | desc "Bundle all entrypoints using Vite."
7 | shared_options
8 | option(:ssr, desc: "Build the SSR entrypoint instead", type: :boolean)
9 | option(:force, desc: "Force the build even if assets have not changed", type: :boolean)
10 | option(:watch, desc: "Start the Rollup watcher and rebuild on files changes", type: :boolean)
11 | option(:profile, desc: "Gather performance metrics from the build ", type: :boolean)
12 |
13 | def call(**options)
14 | super { |args| ViteRuby.commands.build_from_task(*args) }
15 | end
16 | end
17 |
--------------------------------------------------------------------------------
/vite_ruby/lib/vite_ruby/cli/upgrade.rb:
--------------------------------------------------------------------------------
1 | # frozen_string_literal: true
2 |
3 | class ViteRuby::CLI::Upgrade < ViteRuby::CLI::Install
4 | desc "Updates Vite Ruby related gems and npm packages."
5 |
6 | def call(**)
7 | upgrade_ruby_gems
8 | upgrade_npm_packages
9 | end
10 |
11 | protected
12 |
13 | def upgrade_ruby_gems
14 | say "Updating gems"
15 |
16 | libraries = ViteRuby.framework_libraries.map { |_f, library| library.name }
17 |
18 | run_with_capture("bundle update #{libraries.join(" ")}")
19 | end
20 |
21 | # NOTE: Spawn a new process so that it uses the updated vite_ruby.
22 | def upgrade_npm_packages
23 | Kernel.exec("bundle exec vite upgrade_packages")
24 | end
25 | end
26 |
--------------------------------------------------------------------------------
/test/test_app/.gitignore:
--------------------------------------------------------------------------------
1 | /.bundle
2 | /pkg
3 | log
4 | tmp
5 | node_modules
6 | .byebug_history
7 | yarn-debug.log*
8 | yarn-error.log*
9 | .yarn-integrity
10 | gemfiles/*.lock
11 | .DS_Store
12 |
13 | # Vite on Rails
14 | /public/vite*
15 | test/test_app/public/vite-production
16 | node_modules
17 | *.local
18 | .DS_Store
19 |
20 | # Vitepress
21 | dist
22 | examples_dist
23 | node_modules
24 | coverage
25 | .nyc_output
26 | .rpt2_cache
27 | .env
28 | local.log
29 | .DS_Store
30 | e2e/reports
31 | e2e/screenshots
32 | __build__
33 | playground_dist
34 | yarn-error.log
35 | temp
36 | markdown
37 | explorations
38 | selenium-server.log
39 |
40 | # Algolia
41 | .algolia.env
42 |
43 | # Hanami
44 | .env.local
45 | .env.*.local
46 |
--------------------------------------------------------------------------------
/test/test_app/app/frontend/entrypoints/application.js:
--------------------------------------------------------------------------------
1 | // To see this message, add the following to the `` section in your
2 | // views/layouts/application.html.erb
3 | //
4 | // <%= vite_client_tag %>
5 | // <%= vite_javascript_tag 'application' %>
6 | console.log('Vite ⚡️ Rails')
7 |
8 | // Example: Load Rails libraries in Vite.
9 | //
10 | // import * as Turbo from '@hotwired/turbo'
11 | // Turbo.start()
12 | //
13 | // import ActiveStorage from '@rails/activestorage'
14 | // ActiveStorage.start()
15 | //
16 | // // Import all channels.
17 | // const channels = import.meta.glob('./**/*_channel.js', { eager: true })
18 |
19 | // Example: Import a stylesheet in app/frontend/index.css
20 | // import '~/index.css'
21 |
--------------------------------------------------------------------------------
/vite-plugin-rails/scripts/postbuild.mjs:
--------------------------------------------------------------------------------
1 | import fs from 'fs'
2 | import path from 'path'
3 | import { fileURLToPath } from 'url'
4 |
5 | // Note: Once TypeScript 4.5 is out of beta we can drop the whole script.
6 | const __dirname = path.dirname(fileURLToPath(import.meta.url))
7 |
8 | const file = path.join(__dirname, '..', 'dist', 'index.cjs')
9 | const source = fs.readFileSync(file, 'utf-8')
10 | const code = source.replaceAll(
11 | 'isNodeMode || !mod || !mod.__esModule',
12 | '!mod.default',
13 | )
14 |
15 | if (code !== source) {
16 | console.info(`Writing ${file}`)
17 | fs.writeFileSync(file, code)
18 | }
19 | else {
20 | const message = 'Did not find CJS pattern to replace.'
21 | console.warn(message)
22 | }
23 |
--------------------------------------------------------------------------------
/docs/.stylelintrc.js:
--------------------------------------------------------------------------------
1 | module.exports = {
2 | extends: [
3 | 'stylelint-config-standard',
4 | ],
5 | plugins: [
6 | 'stylelint-order',
7 | ],
8 | rules: {
9 | 'no-descending-specificity': null,
10 | 'no-empty-source': null,
11 | 'property-case': null,
12 | 'order/properties-order': [
13 | ['composes'],
14 | { unspecified: 'bottomAlphabetical' },
15 | ],
16 | 'order/order': [
17 | 'at-rules',
18 | 'custom-properties',
19 | 'declarations',
20 | ],
21 | 'order/properties-alphabetical-order': true,
22 | 'selector-pseudo-element-no-unknown': [
23 | true,
24 | {
25 | ignorePseudoElements: ['v-deep'],
26 | },
27 | ],
28 | },
29 | }
30 |
--------------------------------------------------------------------------------
/examples/padrino_blog_tutorial/app/views/layouts/application.haml:
--------------------------------------------------------------------------------
1 | !!! Strict
2 | %html
3 | %head
4 | %title= "Padrino Sample Blog"
5 | = vite_client_tag
6 | = vite_stylesheet_tag 'styles'
7 | = vite_javascript_tag 'application'
8 |
9 | %body
10 | %nav.navbar
11 | %div.container
12 | .navbar-brand
13 | %a.navbar-item{:href => "/"}
14 | %img{:alt => "Logo of Padrino blog", :src => "http://padrinorb.com/images/logo-6475397a.svg"}/
15 | %span.navbar-burger.burger{"data-target" => "navbarMenu"}
16 | %span
17 | %span
18 | %span
19 | #navbarMenu.navbar-menu
20 | .navbar-end
21 | %div.container
22 | #main= yield
23 |
--------------------------------------------------------------------------------
/examples/rails/config/database.yml:
--------------------------------------------------------------------------------
1 | default: &default
2 | adapter: postgresql
3 | pool: <%= ENV.fetch("RAILS_MAX_THREADS") { 5 } %>
4 | host: <%= ENV.fetch("DB_HOST", "localhost") %>
5 | user: <%= ENV.fetch("DB_USER", "") %>
6 | password: <%= ENV.fetch("DB_PASSWORD", "") %>
7 | timeout: 5000
8 |
9 | development:
10 | <<: *default
11 | database: vite_rails_blog_development
12 |
13 | # Warning: The database defined as "test" will be erased and
14 | # re-generated from your development database when you run "rake".
15 | # Do not set this db to the same as development or production.
16 | test:
17 | <<: *default
18 | database: vite_rails_blog_test
19 |
20 | production:
21 | <<: *default
22 | database: vite_rails_blog
23 |
--------------------------------------------------------------------------------
/examples/rails/spec/features/home_spec.rb:
--------------------------------------------------------------------------------
1 | # frozen_string_literal: true
2 |
3 | RSpec.feature 'Home', test_helpers: [:home] do
4 | before { visit(urls.home_path) }
5 |
6 | scenario 'visit home page' do
7 | home.should.have_content('Vite Rails')
8 | end
9 |
10 | scenario 'hmr in the home page when the Vite dev server is running', if: !ENV['CI'] do
11 | raise 'the Vite dev server is not running' unless ViteRuby.instance.dev_server_running?
12 |
13 | home.should.have_content('Vite Rails')
14 |
15 | home.rewrite('Rails', to: 'Ruby')
16 | home.should_now.have_content('Vite Ruby')
17 |
18 | home.rewrite('Ruby', to: 'Rails')
19 | home.should_now.have_content('Vite Rails')
20 | ensure
21 | home.revert_changes
22 | end
23 | end
24 |
--------------------------------------------------------------------------------
/examples/hanami_bookshelf/README.md:
--------------------------------------------------------------------------------
1 | # Hanami Bookshelf
2 |
3 | Welcome to your new Hanami project!
4 |
5 | ## Setup
6 |
7 | How to run tests:
8 |
9 | ```
10 | % bundle exec rake
11 | ```
12 |
13 | How to run the development console:
14 |
15 | ```
16 | % bundle exec hanami console
17 | ```
18 |
19 | How to run the development server:
20 |
21 | ```
22 | % bundle exec hanami server
23 | ```
24 |
25 | How to prepare (create and migrate) DB for `development` and `test` environments:
26 |
27 | ```
28 | % bundle exec hanami db prepare
29 |
30 | % HANAMI_ENV=test bundle exec hanami db prepare
31 | ```
32 |
33 | Explore Hanami [guides](https://guides.hanamirb.org/), [API docs](http://docs.hanamirb.org/1.3.3/), or jump in [chat](http://chat.hanamirb.org) for help. Enjoy! 🌸
34 |
--------------------------------------------------------------------------------
/examples/hanami_bookshelf/Gemfile:
--------------------------------------------------------------------------------
1 | source 'https://rubygems.org'
2 |
3 | ruby '3.1.1'
4 |
5 | gem 'rake'
6 | gem 'hanami'
7 | # gem 'hanami-model', git: 'https://github.com/hanami/model.git', require: false
8 |
9 | # gem 'pg'
10 |
11 | gem 'vite_ruby', path: '../../vite_ruby'
12 |
13 | # gem 'vite_hanami', path: '../../vite_hanami'
14 | gem 'vite_hanami'
15 |
16 | group :development do
17 | # Code reloading
18 | # See: https://guides.hanamirb.org/projects/code-reloading
19 | gem 'shotgun', platforms: :ruby
20 | gem 'hanami-webconsole'
21 | end
22 |
23 | group :test, :development do
24 | gem 'dotenv'
25 | gem 'pry-byebug'
26 | end
27 |
28 | group :test do
29 | gem 'rspec'
30 | gem 'capybara'
31 | end
32 |
33 | group :production do
34 | gem 'puma'
35 | end
36 |
--------------------------------------------------------------------------------
/examples/rails/config/initializers/inflections.rb:
--------------------------------------------------------------------------------
1 | # frozen_string_literal: true
2 | # Be sure to restart your server when you modify this file.
3 |
4 | # Add new inflection rules using the following format. Inflections
5 | # are locale specific, and you may define rules for as many different
6 | # locales as you wish. All of these examples are active by default:
7 | # ActiveSupport::Inflector.inflections(:en) do |inflect|
8 | # inflect.plural /^(ox)$/i, '\1en'
9 | # inflect.singular /^(ox)en/i, '\1'
10 | # inflect.irregular 'person', 'people'
11 | # inflect.uncountable %w( fish sheep )
12 | # end
13 |
14 | # These inflection rules are supported but not enabled by default:
15 | # ActiveSupport::Inflector.inflections(:en) do |inflect|
16 | # inflect.acronym 'RESTful'
17 | # end
18 |
--------------------------------------------------------------------------------
/.github/workflows/js.yml:
--------------------------------------------------------------------------------
1 | name: JS Build & Test
2 |
3 | on: [push, pull_request]
4 |
5 | jobs:
6 | build:
7 | name: Vite Plugin Ruby
8 |
9 | strategy:
10 | matrix:
11 | os: [ubuntu-latest]
12 | node: [20]
13 |
14 | runs-on: ${{ matrix.os }}
15 |
16 | steps:
17 | - uses: actions/checkout@v4
18 |
19 | - uses: pnpm/action-setup@v4
20 | with:
21 | version: 8.6.5
22 |
23 | - uses: actions/setup-node@v4
24 | with:
25 | cache: 'pnpm'
26 | node-version: ${{ matrix.node }}
27 |
28 | - run: pnpm -C vite-plugin-ruby install --frozen-lockfile
29 |
30 | - name: Build
31 | run: pnpm -C vite-plugin-ruby build
32 |
33 | - name: Test
34 | run: pnpm -C vite-plugin-ruby test
35 |
--------------------------------------------------------------------------------
/.rubocop_todo.yml:
--------------------------------------------------------------------------------
1 | # This configuration was generated by
2 | # `rubocop --auto-gen-config`
3 | # on 2024-11-05 13:37:33 UTC using RuboCop version 1.66.1.
4 | # The point is for the user to remove these configuration records
5 | # one by one as the offenses are removed from the code base.
6 | # Note that changes in the inspected code, or installation of new
7 | # versions of RuboCop, may require this file to be generated again.
8 |
9 | # Offense count: 1
10 | # Configuration parameters: AllowComments, AllowEmptyLambdas.
11 | Lint/EmptyBlock:
12 | Exclude:
13 | - 'test/mounted_app/test/dummy/config/initializers/content_security_policy.rb'
14 |
15 | # Offense count: 1
16 | # Configuration parameters: AllowComments.
17 | Lint/EmptyClass:
18 | Exclude:
19 | - 'test/test_app/config/application.rb'
20 |
--------------------------------------------------------------------------------
/examples/rails/app/frontend/entrypoints/application.ts:
--------------------------------------------------------------------------------
1 | // Example: Load Rails libraries in Vite.
2 | import * as Turbo from '@hotwired/turbo'
3 | import * as ActiveStorage from '@rails/activestorage'
4 |
5 | // Enable Windi CSS styles and preflight
6 | import 'windi.css'
7 |
8 | // Example: Import a stylesheet in app/frontend/styles
9 | import '~/styles/theme.css'
10 |
11 | import '~/entrypoints/example_import'
12 | setTimeout(() => import('~/outer_import'), 5000)
13 |
14 | // Example: Import from an aliased path.
15 | import '@administrator/timer'
16 |
17 | // Import all channels.
18 | import.meta.glob('../channels/**/*_channel.js', { eager: true })
19 |
20 | Turbo.start()
21 | ActiveStorage.start()
22 |
23 | console.log('Visit the guide for more information: ', 'https://vite-ruby.netlify.app/guide/rails')
24 |
--------------------------------------------------------------------------------
/vite_ruby/default.vite.json:
--------------------------------------------------------------------------------
1 | {
2 | "additionalEntrypoints": ["~/{assets,fonts,icons,images}/**/*"],
3 | "assetHost": null,
4 | "assetsDir": "assets",
5 | "autoBuild": false,
6 | "buildCacheDir": "tmp/cache/vite",
7 | "publicOutputDir": "vite",
8 | "configPath": "config/vite.json",
9 | "devServerConnectTimeout": 0.01,
10 | "packageManager": null,
11 | "publicDir": "public",
12 | "entrypointsDir": "entrypoints",
13 | "sourceCodeDir": "app/frontend",
14 | "skipCompatibilityCheck": false,
15 | "skipProxy": false,
16 | "host": "localhost",
17 | "https": null,
18 | "port": 3036,
19 | "hideBuildConsoleOutput": false,
20 | "viteBinPath": null,
21 | "watchAdditionalPaths": [],
22 | "base": "",
23 | "ssrBuildEnabled": false,
24 | "ssrEntrypoint": "~/ssr/ssr.{js,ts,jsx,tsx}",
25 | "ssrOutputDir": "public/vite-ssr"
26 | }
27 |
--------------------------------------------------------------------------------
/vite-plugin-rails/CHANGELOG.md:
--------------------------------------------------------------------------------
1 | # 0.5.0 (2023-11-16)
2 |
3 |
4 | ### Bug Fixes
5 |
6 | * ssr incompatibility with vite 4 ([#345](https://github.com/ElMassimo/vite_ruby/issues/345)) ([3491bde](https://github.com/ElMassimo/vite_ruby/commit/3491bdedad2b0fcb8a1895efa4dafb3874d14efd)), closes [#333](https://github.com/ElMassimo/vite_ruby/issues/333)
7 |
8 |
9 | ### Features
10 |
11 | * create vite-plugin-rails, an opinionated version of `vite-plugin-ruby` ([#282](https://github.com/ElMassimo/vite_ruby/issues/282)) ([16375fb](https://github.com/ElMassimo/vite_ruby/commit/16375fb1f6f2bf86dff935ca3aaf91c333a796ff))
12 | * upgrade vite-plugin-rails dependencies to support vite 5 ([b4eade9](https://github.com/ElMassimo/vite_ruby/commit/b4eade9b92413172501df8f762a9c0164633ee95))
13 |
14 |
15 |
16 | ## vite-plugin-rails 0.1.0 (2022-10-19)
17 |
18 | - Initial Release
19 |
--------------------------------------------------------------------------------
/vite-plugin-ruby/default.vite.json:
--------------------------------------------------------------------------------
1 | {
2 | "additionalEntrypoints": ["~/{assets,fonts,icons,images}/**/*"],
3 | "assetHost": null,
4 | "assetsDir": "assets",
5 | "autoBuild": false,
6 | "buildCacheDir": "tmp/cache/vite",
7 | "publicOutputDir": "vite",
8 | "configPath": "config/vite.json",
9 | "devServerConnectTimeout": 0.01,
10 | "packageManager": null,
11 | "publicDir": "public",
12 | "entrypointsDir": "entrypoints",
13 | "sourceCodeDir": "app/frontend",
14 | "skipCompatibilityCheck": false,
15 | "skipProxy": false,
16 | "host": "localhost",
17 | "https": null,
18 | "port": 3036,
19 | "hideBuildConsoleOutput": false,
20 | "viteBinPath": null,
21 | "watchAdditionalPaths": [],
22 | "base": "",
23 | "ssrBuildEnabled": false,
24 | "ssrEntrypoint": "~/ssr/ssr.{js,ts,jsx,tsx}",
25 | "ssrOutputDir": "public/vite-ssr"
26 | }
27 |
--------------------------------------------------------------------------------
/examples/rails/example_engine/app/assets/stylesheets/administrator/application.css:
--------------------------------------------------------------------------------
1 | /*
2 | * This is a manifest file that'll be compiled into application.css, which will include all the files
3 | * listed below.
4 | *
5 | * Any CSS and SCSS file within this directory, lib/assets/stylesheets, vendor/assets/stylesheets,
6 | * or any plugin's vendor/assets/stylesheets directory can be referenced here using a relative path.
7 | *
8 | * You're free to add application-wide styles to this file and they'll appear at the bottom of the
9 | * compiled file so the styles you add here take precedence over styles defined in any other CSS/SCSS
10 | * files in this directory. Styles in this file should be added after the last require_* statement.
11 | * It is generally better to create a new file per style scope.
12 | *
13 | *= require_tree .
14 | *= require_self
15 | */
16 |
--------------------------------------------------------------------------------
/examples/padrino_blog_tutorial/config/boot.rb:
--------------------------------------------------------------------------------
1 | # frozen_string_literal: true
2 |
3 | # Defines our constants
4 | RACK_ENV = ENV['RACK_ENV'] ||= 'development' unless defined?(RACK_ENV)
5 | PADRINO_ROOT = File.expand_path('..', __dir__) unless defined?(PADRINO_ROOT)
6 |
7 | # Load our dependencies
8 | require 'bundler/setup'
9 | Bundler.require(:default, RACK_ENV)
10 |
11 | ##
12 | # Require initializers before all other dependencies.
13 | # Dependencies from 'config' folder are NOT re-required on reload.
14 | #
15 | Padrino.dependency_paths.unshift Padrino.root('config/initializers/*.rb')
16 |
17 | ##
18 | # Add your before (RE)load hooks here
19 | # These hooks are run before any dependencies are required.
20 | #
21 | Padrino.before_load do
22 | end
23 |
24 | ##
25 | # Add your after (RE)load hooks here
26 | #
27 | Padrino.after_load do
28 | end
29 |
30 | Padrino.load!
31 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | /.bundle
2 | pkg
3 | log
4 | tmp
5 | node_modules
6 | .byebug_history
7 | yarn-debug.log*
8 | yarn-error.log*
9 | .yarn-integrity
10 | gemfiles/*.lock
11 | .DS_Store
12 |
13 | # Vite on Rails
14 | /public/vite
15 | /public/vite-dev
16 | /public/vite-test
17 | test/test_app/public/vite-production
18 | node_modules
19 | *.local
20 | .DS_Store
21 |
22 | # Vitepress
23 | dist
24 | examples_dist
25 | node_modules
26 | coverage
27 | .nyc_output
28 | .rpt2_cache
29 | .env
30 | local.log
31 | .DS_Store
32 | e2e/reports
33 | e2e/screenshots
34 | __build__
35 | playground_dist
36 | yarn-error.log
37 | *.log
38 | temp
39 | markdown
40 | explorations
41 | selenium-server.log
42 |
43 | # Algolia
44 | .algolia.env
45 |
46 | # Hanami
47 | .env.local
48 | .env.*.local
49 |
50 | .pnpm-debug.log
51 | test/mounted_app/test/dummy/bin/vite
52 | test/mounted_app/test/dummy/bin/racc
53 |
54 | examples/with_engine
55 |
--------------------------------------------------------------------------------
/examples/hanami_bookshelf/apps/web/frontend/entrypoints/styles.scss:
--------------------------------------------------------------------------------
1 | *, ::after, ::before {
2 | box-sizing: border-box;
3 | }
4 |
5 | html {
6 | font-family: ui-sans-serif, system-ui, -apple-system, system-ui, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans", sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol", "Noto Color Emoji";
7 | line-height: 1.5;
8 | }
9 |
10 | body {
11 | font-family: inherit;
12 | line-height: inherit;
13 | margin: 0;
14 | }
15 |
16 | header {
17 | display: grid;
18 | height: 100vh;
19 | margin: 0 auto;
20 | padding-bottom: 20vh;
21 | place-content: center;
22 | }
23 |
24 | .logo {
25 | height: 0;
26 | opacity: 0;
27 | }
28 |
29 | .hero {
30 | box-sizing: border-box;
31 | font-size: clamp(4rem, 10vw, 4.5rem);
32 | line-height: 1;
33 | font-weight: 800;
34 | height: 128px;
35 | margin: 0;
36 | text-align: center;
37 | }
38 |
--------------------------------------------------------------------------------
/bin/rake:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env ruby
2 | # frozen_string_literal: true
3 |
4 | #
5 | # This file was generated by Bundler.
6 | #
7 | # The application 'rake' is installed as part of a gem, and
8 | # this file is here to facilitate running it.
9 | #
10 |
11 | require "pathname"
12 | ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../../Gemfile",
13 | Pathname.new(__FILE__).realpath)
14 |
15 | bundle_binstub = File.expand_path("bundle", __dir__)
16 |
17 | if File.file?(bundle_binstub)
18 | if File.read(bundle_binstub, 300).include?("This file was generated by Bundler")
19 | load(bundle_binstub)
20 | else
21 | abort("Your `bin/bundle` was not generated by Bundler, so this binstub cannot run.
22 | Replace `bin/bundle` by running `bundle binstubs bundler --force`, then run this command again.")
23 | end
24 | end
25 |
26 | require "rubygems"
27 | require "bundler/setup"
28 |
29 | load Gem.bin_path("rake", "rake")
30 |
--------------------------------------------------------------------------------
/test/test_app/public/vite-production/.vite/manifest-assets.json:
--------------------------------------------------------------------------------
1 | {
2 | "entrypoints/sassy.scss": {
3 | "file": "assets/sassy.3560956f.css",
4 | "src": "entrypoints/sassy.scss"
5 | },
6 | "../assets/theme.css": {
7 | "file": "assets/theme.e6d9734b.css",
8 | "src": "app/assets/theme.css"
9 | },
10 | "entrypoints/app.css": {
11 | "file": "assets/app.517bf154.css",
12 | "src": "entrypoints/app.css"
13 | },
14 | "images/logo.png": {
15 | "file": "assets/logo.f42fb7ea.png",
16 | "src": "images/logo.png"
17 | },
18 | "images/logo-2x.png": {
19 | "file": "assets/logo-2x.bs8d7a77.png",
20 | "src": "images/logo-2x.png"
21 | },
22 | "images/logo.svg": {
23 | "file": "assets/logo.322aae0c.svg",
24 | "src": "images/logo.svg"
25 | },
26 | "../assets/logo.png": {
27 | "file": "assets/logo.03d6d6da.png",
28 | "src": "app/assets/logo.png"
29 | }
30 | }
31 |
--------------------------------------------------------------------------------
/bin/rubocop:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env ruby
2 | # frozen_string_literal: true
3 |
4 | #
5 | # This file was generated by Bundler.
6 | #
7 | # The application 'rubocop' is installed as part of a gem, and
8 | # this file is here to facilitate running it.
9 | #
10 |
11 | require "pathname"
12 | ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../../Gemfile",
13 | Pathname.new(__FILE__).realpath)
14 |
15 | bundle_binstub = File.expand_path("bundle", __dir__)
16 |
17 | if File.file?(bundle_binstub)
18 | if File.read(bundle_binstub, 300).include?("This file was generated by Bundler")
19 | load(bundle_binstub)
20 | else
21 | abort("Your `bin/bundle` was not generated by Bundler, so this binstub cannot run.
22 | Replace `bin/bundle` by running `bundle binstubs bundler --force`, then run this command again.")
23 | end
24 | end
25 |
26 | require "rubygems"
27 | require "bundler/setup"
28 |
29 | load Gem.bin_path("rubocop", "rubocop")
30 |
--------------------------------------------------------------------------------
/examples/rails/bin/vite:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env ruby
2 | # frozen_string_literal: true
3 |
4 | #
5 | # This file was generated by Bundler.
6 | #
7 | # The application 'vite' is installed as part of a gem, and
8 | # this file is here to facilitate running it.
9 | #
10 |
11 | require "pathname"
12 | ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../../Gemfile",
13 | Pathname.new(__FILE__).realpath)
14 |
15 | bundle_binstub = File.expand_path("../bundle", __FILE__)
16 |
17 | if File.file?(bundle_binstub)
18 | if File.read(bundle_binstub, 300) =~ /This file was generated by Bundler/
19 | load(bundle_binstub)
20 | else
21 | abort("Your `bin/bundle` was not generated by Bundler, so this binstub cannot run.
22 | Replace `bin/bundle` by running `bundle binstubs bundler --force`, then run this command again.")
23 | end
24 | end
25 |
26 | require "rubygems"
27 | require "bundler/setup"
28 |
29 | load Gem.bin_path("vite_ruby", "vite")
30 |
--------------------------------------------------------------------------------
/test/test_app/bin/vite:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env ruby
2 | # frozen_string_literal: true
3 |
4 | #
5 | # This file was generated by Bundler.
6 | #
7 | # The application 'vite' is installed as part of a gem, and
8 | # this file is here to facilitate running it.
9 | #
10 |
11 | require "pathname"
12 | ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../../Gemfile",
13 | Pathname.new(__FILE__).realpath)
14 |
15 | bundle_binstub = File.expand_path("bundle", __dir__)
16 |
17 | if File.file?(bundle_binstub)
18 | if File.read(bundle_binstub, 300).include?("This file was generated by Bundler")
19 | load(bundle_binstub)
20 | else
21 | abort("Your `bin/bundle` was not generated by Bundler, so this binstub cannot run.
22 | Replace `bin/bundle` by running `bundle binstubs bundler --force`, then run this command again.")
23 | end
24 | end
25 |
26 | require "rubygems"
27 | require "bundler/setup"
28 |
29 | load Gem.bin_path("vite_ruby", "vite")
30 |
--------------------------------------------------------------------------------
/examples/hanami_bookshelf/bin/rake:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env ruby
2 | # frozen_string_literal: true
3 |
4 | #
5 | # This file was generated by Bundler.
6 | #
7 | # The application 'rake' is installed as part of a gem, and
8 | # this file is here to facilitate running it.
9 | #
10 |
11 | require "pathname"
12 | ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../../Gemfile",
13 | Pathname.new(__FILE__).realpath)
14 |
15 | bundle_binstub = File.expand_path("../bundle", __FILE__)
16 |
17 | if File.file?(bundle_binstub)
18 | if File.read(bundle_binstub, 300) =~ /This file was generated by Bundler/
19 | load(bundle_binstub)
20 | else
21 | abort("Your `bin/bundle` was not generated by Bundler, so this binstub cannot run.
22 | Replace `bin/bundle` by running `bundle binstubs bundler --force`, then run this command again.")
23 | end
24 | end
25 |
26 | require "rubygems"
27 | require "bundler/setup"
28 |
29 | load Gem.bin_path("rake", "rake")
30 |
--------------------------------------------------------------------------------
/examples/rails/bin/rspec:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env ruby
2 | # frozen_string_literal: true
3 |
4 | #
5 | # This file was generated by Bundler.
6 | #
7 | # The application 'rspec' is installed as part of a gem, and
8 | # this file is here to facilitate running it.
9 | #
10 |
11 | require "pathname"
12 | ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../../Gemfile",
13 | Pathname.new(__FILE__).realpath)
14 |
15 | bundle_binstub = File.expand_path("../bundle", __FILE__)
16 |
17 | if File.file?(bundle_binstub)
18 | if File.read(bundle_binstub, 300) =~ /This file was generated by Bundler/
19 | load(bundle_binstub)
20 | else
21 | abort("Your `bin/bundle` was not generated by Bundler, so this binstub cannot run.
22 | Replace `bin/bundle` by running `bundle binstubs bundler --force`, then run this command again.")
23 | end
24 | end
25 |
26 | require "rubygems"
27 | require "bundler/setup"
28 |
29 | load Gem.bin_path("rspec-core", "rspec")
30 |
--------------------------------------------------------------------------------
/examples/hanami_bookshelf/bin/vite:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env ruby
2 | # frozen_string_literal: true
3 |
4 | #
5 | # This file was generated by Bundler.
6 | #
7 | # The application 'vite' is installed as part of a gem, and
8 | # this file is here to facilitate running it.
9 | #
10 |
11 | require "pathname"
12 | ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../../Gemfile",
13 | Pathname.new(__FILE__).realpath)
14 |
15 | bundle_binstub = File.expand_path("../bundle", __FILE__)
16 |
17 | if File.file?(bundle_binstub)
18 | if File.read(bundle_binstub, 300) =~ /This file was generated by Bundler/
19 | load(bundle_binstub)
20 | else
21 | abort("Your `bin/bundle` was not generated by Bundler, so this binstub cannot run.
22 | Replace `bin/bundle` by running `bundle binstubs bundler --force`, then run this command again.")
23 | end
24 | end
25 |
26 | require "rubygems"
27 | require "bundler/setup"
28 |
29 | load Gem.bin_path("vite_ruby", "vite")
30 |
--------------------------------------------------------------------------------
/examples/padrino_blog_tutorial/bin/rake:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env ruby
2 | # frozen_string_literal: true
3 |
4 | #
5 | # This file was generated by Bundler.
6 | #
7 | # The application 'rake' is installed as part of a gem, and
8 | # this file is here to facilitate running it.
9 | #
10 |
11 | require "pathname"
12 | ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../../Gemfile",
13 | Pathname.new(__FILE__).realpath)
14 |
15 | bundle_binstub = File.expand_path("../bundle", __FILE__)
16 |
17 | if File.file?(bundle_binstub)
18 | if File.read(bundle_binstub, 300) =~ /This file was generated by Bundler/
19 | load(bundle_binstub)
20 | else
21 | abort("Your `bin/bundle` was not generated by Bundler, so this binstub cannot run.
22 | Replace `bin/bundle` by running `bundle binstubs bundler --force`, then run this command again.")
23 | end
24 | end
25 |
26 | require "rubygems"
27 | require "bundler/setup"
28 |
29 | load Gem.bin_path("rake", "rake")
30 |
--------------------------------------------------------------------------------
/examples/rails/example_engine/bin/rake:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env ruby
2 | # frozen_string_literal: true
3 |
4 | #
5 | # This file was generated by Bundler.
6 | #
7 | # The application 'rake' is installed as part of a gem, and
8 | # this file is here to facilitate running it.
9 | #
10 |
11 | require "pathname"
12 | ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../../Gemfile",
13 | Pathname.new(__FILE__).realpath)
14 |
15 | bundle_binstub = File.expand_path("../bundle", __FILE__)
16 |
17 | if File.file?(bundle_binstub)
18 | if File.read(bundle_binstub, 300) =~ /This file was generated by Bundler/
19 | load(bundle_binstub)
20 | else
21 | abort("Your `bin/bundle` was not generated by Bundler, so this binstub cannot run.
22 | Replace `bin/bundle` by running `bundle binstubs bundler --force`, then run this command again.")
23 | end
24 | end
25 |
26 | require "rubygems"
27 | require "bundler/setup"
28 |
29 | load Gem.bin_path("rake", "rake")
30 |
--------------------------------------------------------------------------------
/test/mounted_app/test/dummy/bin/m:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env ruby
2 | # frozen_string_literal: true
3 |
4 | #
5 | # This file was generated by Bundler.
6 | #
7 | # The application 'm' is installed as part of a gem, and
8 | # this file is here to facilitate running it.
9 | #
10 |
11 | require "pathname"
12 | ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../../../../../../Gemfile",
13 | Pathname.new(__FILE__).realpath)
14 |
15 | bundle_binstub = File.expand_path("../bundle", __FILE__)
16 |
17 | if File.file?(bundle_binstub)
18 | if File.read(bundle_binstub, 300) =~ /This file was generated by Bundler/
19 | load(bundle_binstub)
20 | else
21 | abort("Your `bin/bundle` was not generated by Bundler, so this binstub cannot run.
22 | Replace `bin/bundle` by running `bundle binstubs bundler --force`, then run this command again.")
23 | end
24 | end
25 |
26 | require "rubygems"
27 | require "bundler/setup"
28 |
29 | load Gem.bin_path("m", "m")
30 |
--------------------------------------------------------------------------------
/examples/padrino_blog_tutorial/bin/vite:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env ruby
2 | # frozen_string_literal: true
3 |
4 | #
5 | # This file was generated by Bundler.
6 | #
7 | # The application 'vite' is installed as part of a gem, and
8 | # this file is here to facilitate running it.
9 | #
10 |
11 | require "pathname"
12 | ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../../Gemfile",
13 | Pathname.new(__FILE__).realpath)
14 |
15 | bundle_binstub = File.expand_path("../bundle", __FILE__)
16 |
17 | if File.file?(bundle_binstub)
18 | if File.read(bundle_binstub, 300) =~ /This file was generated by Bundler/
19 | load(bundle_binstub)
20 | else
21 | abort("Your `bin/bundle` was not generated by Bundler, so this binstub cannot run.
22 | Replace `bin/bundle` by running `bundle binstubs bundler --force`, then run this command again.")
23 | end
24 | end
25 |
26 | require "rubygems"
27 | require "bundler/setup"
28 |
29 | load Gem.bin_path("vite_ruby", "vite")
30 |
--------------------------------------------------------------------------------
/examples/rails/example_engine/bin/vite:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env ruby
2 | # frozen_string_literal: true
3 |
4 | #
5 | # This file was generated by Bundler.
6 | #
7 | # The application 'vite' is installed as part of a gem, and
8 | # this file is here to facilitate running it.
9 | #
10 |
11 | require "pathname"
12 | ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../../Gemfile",
13 | Pathname.new(__FILE__).realpath)
14 |
15 | bundle_binstub = File.expand_path("../bundle", __FILE__)
16 |
17 | if File.file?(bundle_binstub)
18 | if File.read(bundle_binstub, 300) =~ /This file was generated by Bundler/
19 | load(bundle_binstub)
20 | else
21 | abort("Your `bin/bundle` was not generated by Bundler, so this binstub cannot run.
22 | Replace `bin/bundle` by running `bundle binstubs bundler --force`, then run this command again.")
23 | end
24 | end
25 |
26 | require "rubygems"
27 | require "bundler/setup"
28 |
29 | load Gem.bin_path("vite_ruby", "vite")
30 |
--------------------------------------------------------------------------------
/test/mounted_app/test/dummy/bin/pry:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env ruby
2 | # frozen_string_literal: true
3 |
4 | #
5 | # This file was generated by Bundler.
6 | #
7 | # The application 'pry' is installed as part of a gem, and
8 | # this file is here to facilitate running it.
9 | #
10 |
11 | require "pathname"
12 | ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../../../../../../Gemfile",
13 | Pathname.new(__FILE__).realpath)
14 |
15 | bundle_binstub = File.expand_path("../bundle", __FILE__)
16 |
17 | if File.file?(bundle_binstub)
18 | if File.read(bundle_binstub, 300) =~ /This file was generated by Bundler/
19 | load(bundle_binstub)
20 | else
21 | abort("Your `bin/bundle` was not generated by Bundler, so this binstub cannot run.
22 | Replace `bin/bundle` by running `bundle binstubs bundler --force`, then run this command again.")
23 | end
24 | end
25 |
26 | require "rubygems"
27 | require "bundler/setup"
28 |
29 | load Gem.bin_path("pry", "pry")
30 |
--------------------------------------------------------------------------------
/examples/rails/test_helpers/home_test_helper.rb:
--------------------------------------------------------------------------------
1 | # frozen_string_literal: true
2 |
3 | class HomeTestHelper < BaseTestHelper
4 | HERO_PATH = 'app/frontend/components/Hero.jsx'
5 |
6 | # Aliases: Semantic aliases for locators, can be used in most DSL methods.
7 | aliases(
8 | el: 'header',
9 | )
10 |
11 | # Finders: A convenient way to get related data or nested elements.
12 |
13 | # Actions: Encapsulate complex actions to provide a cleaner interface.
14 | # Public: Allows to test HMR in the test environment.
15 | def rewrite(text, to:)
16 | new_content = File.read(HERO_PATH).sub(text, to)
17 | File.open(HERO_PATH, 'w') { |file| file.write(new_content) }
18 | end
19 |
20 | def revert_changes
21 | `git checkout #{ HERO_PATH }`
22 | end
23 |
24 | # Assertions: Check on element properties, used with `should` and `should_not`.
25 |
26 | # Background: Helpers to add/modify/delete data in the database or session.
27 | end
28 |
--------------------------------------------------------------------------------
/test/mounted_app/test/dummy/bin/rake:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env ruby
2 | # frozen_string_literal: true
3 |
4 | #
5 | # This file was generated by Bundler.
6 | #
7 | # The application 'rake' is installed as part of a gem, and
8 | # this file is here to facilitate running it.
9 | #
10 |
11 | require "pathname"
12 | ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../../../../../../Gemfile",
13 | Pathname.new(__FILE__).realpath)
14 |
15 | bundle_binstub = File.expand_path("../bundle", __FILE__)
16 |
17 | if File.file?(bundle_binstub)
18 | if File.read(bundle_binstub, 300) =~ /This file was generated by Bundler/
19 | load(bundle_binstub)
20 | else
21 | abort("Your `bin/bundle` was not generated by Bundler, so this binstub cannot run.
22 | Replace `bin/bundle` by running `bundle binstubs bundler --force`, then run this command again.")
23 | end
24 | end
25 |
26 | require "rubygems"
27 | require "bundler/setup"
28 |
29 | load Gem.bin_path("rake", "rake")
30 |
--------------------------------------------------------------------------------
/test/mounted_app/test/dummy/bin/thor:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env ruby
2 | # frozen_string_literal: true
3 |
4 | #
5 | # This file was generated by Bundler.
6 | #
7 | # The application 'thor' is installed as part of a gem, and
8 | # this file is here to facilitate running it.
9 | #
10 |
11 | require "pathname"
12 | ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../../../../../../Gemfile",
13 | Pathname.new(__FILE__).realpath)
14 |
15 | bundle_binstub = File.expand_path("../bundle", __FILE__)
16 |
17 | if File.file?(bundle_binstub)
18 | if File.read(bundle_binstub, 300) =~ /This file was generated by Bundler/
19 | load(bundle_binstub)
20 | else
21 | abort("Your `bin/bundle` was not generated by Bundler, so this binstub cannot run.
22 | Replace `bin/bundle` by running `bundle binstubs bundler --force`, then run this command again.")
23 | end
24 | end
25 |
26 | require "rubygems"
27 | require "bundler/setup"
28 |
29 | load Gem.bin_path("thor", "thor")
30 |
--------------------------------------------------------------------------------
/test/mounted_app/test/dummy/bin/rackup:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env ruby
2 | # frozen_string_literal: true
3 |
4 | #
5 | # This file was generated by Bundler.
6 | #
7 | # The application 'rackup' is installed as part of a gem, and
8 | # this file is here to facilitate running it.
9 | #
10 |
11 | require "pathname"
12 | ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../../../../../../Gemfile",
13 | Pathname.new(__FILE__).realpath)
14 |
15 | bundle_binstub = File.expand_path("../bundle", __FILE__)
16 |
17 | if File.file?(bundle_binstub)
18 | if File.read(bundle_binstub, 300) =~ /This file was generated by Bundler/
19 | load(bundle_binstub)
20 | else
21 | abort("Your `bin/bundle` was not generated by Bundler, so this binstub cannot run.
22 | Replace `bin/bundle` by running `bundle binstubs bundler --force`, then run this command again.")
23 | end
24 | end
25 |
26 | require "rubygems"
27 | require "bundler/setup"
28 |
29 | load Gem.bin_path("rack", "rackup")
30 |
--------------------------------------------------------------------------------
/test/mounted_app/test/dummy/bin/rails:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env ruby
2 | # frozen_string_literal: true
3 |
4 | #
5 | # This file was generated by Bundler.
6 | #
7 | # The application 'rails' is installed as part of a gem, and
8 | # this file is here to facilitate running it.
9 | #
10 |
11 | require "pathname"
12 | ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../../../../../../Gemfile",
13 | Pathname.new(__FILE__).realpath)
14 |
15 | bundle_binstub = File.expand_path("../bundle", __FILE__)
16 |
17 | if File.file?(bundle_binstub)
18 | if File.read(bundle_binstub, 300) =~ /This file was generated by Bundler/
19 | load(bundle_binstub)
20 | else
21 | abort("Your `bin/bundle` was not generated by Bundler, so this binstub cannot run.
22 | Replace `bin/bundle` by running `bundle binstubs bundler --force`, then run this command again.")
23 | end
24 | end
25 |
26 | require "rubygems"
27 | require "bundler/setup"
28 |
29 | load Gem.bin_path("railties", "rails")
30 |
--------------------------------------------------------------------------------
/examples/padrino_blog_tutorial/bin/padrino:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env ruby
2 | # frozen_string_literal: true
3 |
4 | #
5 | # This file was generated by Bundler.
6 | #
7 | # The application 'padrino' is installed as part of a gem, and
8 | # this file is here to facilitate running it.
9 | #
10 |
11 | require "pathname"
12 | ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../../Gemfile",
13 | Pathname.new(__FILE__).realpath)
14 |
15 | bundle_binstub = File.expand_path("../bundle", __FILE__)
16 |
17 | if File.file?(bundle_binstub)
18 | if File.read(bundle_binstub, 300) =~ /This file was generated by Bundler/
19 | load(bundle_binstub)
20 | else
21 | abort("Your `bin/bundle` was not generated by Bundler, so this binstub cannot run.
22 | Replace `bin/bundle` by running `bundle binstubs bundler --force`, then run this command again.")
23 | end
24 | end
25 |
26 | require "rubygems"
27 | require "bundler/setup"
28 |
29 | load Gem.bin_path("padrino-core", "padrino")
30 |
--------------------------------------------------------------------------------
/test/mounted_app/test/dummy/bin/byebug:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env ruby
2 | # frozen_string_literal: true
3 |
4 | #
5 | # This file was generated by Bundler.
6 | #
7 | # The application 'byebug' is installed as part of a gem, and
8 | # this file is here to facilitate running it.
9 | #
10 |
11 | require "pathname"
12 | ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../../../../../../Gemfile",
13 | Pathname.new(__FILE__).realpath)
14 |
15 | bundle_binstub = File.expand_path("../bundle", __FILE__)
16 |
17 | if File.file?(bundle_binstub)
18 | if File.read(bundle_binstub, 300) =~ /This file was generated by Bundler/
19 | load(bundle_binstub)
20 | else
21 | abort("Your `bin/bundle` was not generated by Bundler, so this binstub cannot run.
22 | Replace `bin/bundle` by running `bundle binstubs bundler --force`, then run this command again.")
23 | end
24 | end
25 |
26 | require "rubygems"
27 | require "bundler/setup"
28 |
29 | load Gem.bin_path("byebug", "byebug")
30 |
--------------------------------------------------------------------------------
/test/mounted_app/test/dummy/bin/coderay:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env ruby
2 | # frozen_string_literal: true
3 |
4 | #
5 | # This file was generated by Bundler.
6 | #
7 | # The application 'coderay' is installed as part of a gem, and
8 | # this file is here to facilitate running it.
9 | #
10 |
11 | require "pathname"
12 | ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../../../../../../Gemfile",
13 | Pathname.new(__FILE__).realpath)
14 |
15 | bundle_binstub = File.expand_path("../bundle", __FILE__)
16 |
17 | if File.file?(bundle_binstub)
18 | if File.read(bundle_binstub, 300) =~ /This file was generated by Bundler/
19 | load(bundle_binstub)
20 | else
21 | abort("Your `bin/bundle` was not generated by Bundler, so this binstub cannot run.
22 | Replace `bin/bundle` by running `bundle binstubs bundler --force`, then run this command again.")
23 | end
24 | end
25 |
26 | require "rubygems"
27 | require "bundler/setup"
28 |
29 | load Gem.bin_path("coderay", "coderay")
30 |
--------------------------------------------------------------------------------
/test/mounted_app/test/dummy/bin/rubocop:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env ruby
2 | # frozen_string_literal: true
3 |
4 | #
5 | # This file was generated by Bundler.
6 | #
7 | # The application 'rubocop' is installed as part of a gem, and
8 | # this file is here to facilitate running it.
9 | #
10 |
11 | require "pathname"
12 | ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../../../../../../Gemfile",
13 | Pathname.new(__FILE__).realpath)
14 |
15 | bundle_binstub = File.expand_path("../bundle", __FILE__)
16 |
17 | if File.file?(bundle_binstub)
18 | if File.read(bundle_binstub, 300) =~ /This file was generated by Bundler/
19 | load(bundle_binstub)
20 | else
21 | abort("Your `bin/bundle` was not generated by Bundler, so this binstub cannot run.
22 | Replace `bin/bundle` by running `bundle binstubs bundler --force`, then run this command again.")
23 | end
24 | end
25 |
26 | require "rubygems"
27 | require "bundler/setup"
28 |
29 | load Gem.bin_path("rubocop", "rubocop")
30 |
--------------------------------------------------------------------------------
/test/mounted_app/test/dummy/bin/spring:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env ruby
2 | # frozen_string_literal: true
3 |
4 | #
5 | # This file was generated by Bundler.
6 | #
7 | # The application 'spring' is installed as part of a gem, and
8 | # this file is here to facilitate running it.
9 | #
10 |
11 | require "pathname"
12 | ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../../../../../../Gemfile",
13 | Pathname.new(__FILE__).realpath)
14 |
15 | bundle_binstub = File.expand_path("../bundle", __FILE__)
16 |
17 | if File.file?(bundle_binstub)
18 | if File.read(bundle_binstub, 300) =~ /This file was generated by Bundler/
19 | load(bundle_binstub)
20 | else
21 | abort("Your `bin/bundle` was not generated by Bundler, so this binstub cannot run.
22 | Replace `bin/bundle` by running `bundle binstubs bundler --force`, then run this command again.")
23 | end
24 | end
25 |
26 | require "rubygems"
27 | require "bundler/setup"
28 |
29 | load Gem.bin_path("spring", "spring")
30 |
--------------------------------------------------------------------------------
/vite-plugin-ruby/example/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "vite-plugin-ruby-example",
3 | "version": "0.0.0",
4 | "private": true,
5 | "license": "MIT",
6 | "scripts": {
7 | "dev": "cross-env DEBUG=vite-plugin-ruby:* vite --open",
8 | "build": "cross-env DEBUG=vite-plugin-ruby:* vite build --mode production",
9 | "preview": "cross-env RAILS_ENV=production DEBUG=vite-plugin-ruby:* vite preview --open"
10 | },
11 | "devDependencies": {
12 | "@inertiajs/inertia": "^0.11.1",
13 | "@inertiajs/inertia-vue3": "^0.6.0",
14 | "@inertiajs/server": "^0.1.0",
15 | "@vitejs/plugin-legacy": "^5.0.0",
16 | "@vitejs/plugin-vue": "^4.5.0",
17 | "@vue/server-renderer": "^3.3.8",
18 | "@types/node": "^18",
19 | "cross-env": "^7.0.3",
20 | "sass": "^1.59.3",
21 | "terser": "^5.16.6",
22 | "typescript": "^4.9.5",
23 | "vite": "^5.0.0",
24 | "vite-plugin-ruby": "workspace:*",
25 | "vue": "^3.3.8"
26 | }
27 | }
28 |
--------------------------------------------------------------------------------
/vite_hanami/CHANGELOG.md:
--------------------------------------------------------------------------------
1 | # [3.0.0](https://github.com/ElMassimo/vite_ruby/compare/vite_hanami@0.5.3...vite_hanami@3.0.0) (2021-08-16)
2 |
3 | See https://github.com/ElMassimo/vite_ruby/pull/116 for features and breaking changes.
4 |
5 | ## [0.5.3](https://github.com/ElMassimo/vite_ruby/compare/vite_hanami@0.5.2...vite_hanami@0.5.3) (2021-04-21)
6 |
7 |
8 | ### Features
9 |
10 | * Add helpers to enable HMR when using @vitejs/plugin-react-refresh ([a80f286](https://github.com/ElMassimo/vite_ruby/commit/a80f286d4305bbae29ea7cea42a4329a530f43fa))
11 |
12 |
13 |
14 | ## [0.5.2](https://github.com/ElMassimo/vite_ruby/compare/vite_hanami@0.5.1...vite_hanami@0.5.2) (2021-03-07)
15 |
16 | - Add a bounded requirement to `vite_ruby` dependency.
17 |
18 | ## Vite Hanami 0.5.1 (2020-02-10)
19 |
20 | - Install rake tasks in Rakefile by default.
21 |
22 | ## Vite Hanami 0.5.0 (2020-02-09)
23 |
24 | - Initial release, includes installation samples and tag helpers.
25 |
--------------------------------------------------------------------------------
/examples/rails/example_engine/bin/rails:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env ruby
2 | # This command will automatically be run when you run "rails" with Rails gems
3 | # installed from the root of your application.
4 |
5 | ENGINE_ROOT = File.expand_path('..', __dir__)
6 | ENGINE_PATH = File.expand_path('../lib/administrator/engine', __dir__)
7 |
8 | # Set up gems listed in the Gemfile.
9 | ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../Gemfile', __dir__)
10 | require "bundler/setup" if File.exist?(ENV["BUNDLE_GEMFILE"])
11 |
12 | require "rails"
13 | # Pick the frameworks you want:
14 | require "active_model/railtie"
15 | require "active_job/railtie"
16 | # require "active_record/railtie"
17 | # require "active_storage/engine"
18 | require "action_controller/railtie"
19 | # require "action_mailer/railtie"
20 | require "action_view/railtie"
21 | # require "action_cable/engine"
22 | # require "sprockets/railtie"
23 | # require "rails/test_unit/railtie"
24 | require "rails/engine/commands"
25 |
--------------------------------------------------------------------------------
/test/mounted_app/test/dummy/bin/nokogiri:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env ruby
2 | # frozen_string_literal: true
3 |
4 | #
5 | # This file was generated by Bundler.
6 | #
7 | # The application 'nokogiri' is installed as part of a gem, and
8 | # this file is here to facilitate running it.
9 | #
10 |
11 | require "pathname"
12 | ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../../../../../../Gemfile",
13 | Pathname.new(__FILE__).realpath)
14 |
15 | bundle_binstub = File.expand_path("../bundle", __FILE__)
16 |
17 | if File.file?(bundle_binstub)
18 | if File.read(bundle_binstub, 300) =~ /This file was generated by Bundler/
19 | load(bundle_binstub)
20 | else
21 | abort("Your `bin/bundle` was not generated by Bundler, so this binstub cannot run.
22 | Replace `bin/bundle` by running `bundle binstubs bundler --force`, then run this command again.")
23 | end
24 | end
25 |
26 | require "rubygems"
27 | require "bundler/setup"
28 |
29 | load Gem.bin_path("nokogiri", "nokogiri")
30 |
--------------------------------------------------------------------------------
/test/mounted_app/test/dummy/bin/ruby-parse:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env ruby
2 | # frozen_string_literal: true
3 |
4 | #
5 | # This file was generated by Bundler.
6 | #
7 | # The application 'ruby-parse' is installed as part of a gem, and
8 | # this file is here to facilitate running it.
9 | #
10 |
11 | require "pathname"
12 | ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../../../../../../Gemfile",
13 | Pathname.new(__FILE__).realpath)
14 |
15 | bundle_binstub = File.expand_path("../bundle", __FILE__)
16 |
17 | if File.file?(bundle_binstub)
18 | if File.read(bundle_binstub, 300) =~ /This file was generated by Bundler/
19 | load(bundle_binstub)
20 | else
21 | abort("Your `bin/bundle` was not generated by Bundler, so this binstub cannot run.
22 | Replace `bin/bundle` by running `bundle binstubs bundler --force`, then run this command again.")
23 | end
24 | end
25 |
26 | require "rubygems"
27 | require "bundler/setup"
28 |
29 | load Gem.bin_path("parser", "ruby-parse")
30 |
--------------------------------------------------------------------------------
/test/mounted_app/test/dummy/bin/sprockets:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env ruby
2 | # frozen_string_literal: true
3 |
4 | #
5 | # This file was generated by Bundler.
6 | #
7 | # The application 'sprockets' is installed as part of a gem, and
8 | # this file is here to facilitate running it.
9 | #
10 |
11 | require "pathname"
12 | ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../../../../../../Gemfile",
13 | Pathname.new(__FILE__).realpath)
14 |
15 | bundle_binstub = File.expand_path("../bundle", __FILE__)
16 |
17 | if File.file?(bundle_binstub)
18 | if File.read(bundle_binstub, 300) =~ /This file was generated by Bundler/
19 | load(bundle_binstub)
20 | else
21 | abort("Your `bin/bundle` was not generated by Bundler, so this binstub cannot run.
22 | Replace `bin/bundle` by running `bundle binstubs bundler --force`, then run this command again.")
23 | end
24 | end
25 |
26 | require "rubygems"
27 | require "bundler/setup"
28 |
29 | load Gem.bin_path("sprockets", "sprockets")
30 |
--------------------------------------------------------------------------------
/examples/rails/README.md:
--------------------------------------------------------------------------------
1 |
2 | Vite ⚡️ Rails
3 |
4 |
5 | [vite_rails]: https://github.com/ElMassimo/vite_ruby
6 | [heroku]: https://vite-rails-demo.herokuapp.com/
7 | [live demo]: https://vite-rails-demo.herokuapp.com/
8 |
9 | This app is an example using [vite_rails] to manage assets with Vite.
10 |
11 | A [live demo] is running on [Heroku].
12 |
13 | ## Installation 💿
14 |
15 | If using Docker, run `bin/docker_setup` to build the images and create the db.
16 |
17 | Alternatively, you can run:
18 |
19 | - bundle install: Install the ruby gems
20 | - yarn install: Install the npm packages
21 | - bin/rake db:create db:migrate: Create the database and tables
22 |
23 | ## Development 🚀
24 |
25 | If using Docker, run `bin/docker` to start the services.
26 |
27 | Alternatively, you can run:
28 |
29 | - bin/rails s: Starts the Rails dev server
30 | - bin/vite dev: Starts the Vite.js dev server
31 |
--------------------------------------------------------------------------------
/test/dev_server_test.rb:
--------------------------------------------------------------------------------
1 | # frozen_string_literal: true
2 |
3 | require "test_helper"
4 |
5 | class DevServerTest < ViteRuby::Test
6 | def test_not_running
7 | refute_predicate ViteRuby.instance, :dev_server_running?
8 |
9 | refresh_config(mode: "development")
10 |
11 | refute_predicate ViteRuby.instance, :dev_server_running?
12 |
13 | running_checked_at = ViteRuby.instance.instance_variable_get(:@running_checked_at)
14 |
15 | assert_in_delta(Time.now.to_f, running_checked_at.to_f, 0.01)
16 | end
17 |
18 | def test_running
19 | refresh_config(mode: "development")
20 | ViteRuby.instance.instance_variable_set(:@running, true)
21 | ViteRuby.instance.instance_variable_set(:@running_checked_at, Time.now)
22 |
23 | assert_predicate ViteRuby.instance, :dev_server_running?
24 | ensure
25 | ViteRuby.instance.remove_instance_variable(:@running)
26 | ViteRuby.instance.remove_instance_variable(:@running_checked_at)
27 | end
28 | end
29 |
--------------------------------------------------------------------------------
/test/mounted_app/test/dummy/bin/ruby-rewrite:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env ruby
2 | # frozen_string_literal: true
3 |
4 | #
5 | # This file was generated by Bundler.
6 | #
7 | # The application 'ruby-rewrite' is installed as part of a gem, and
8 | # this file is here to facilitate running it.
9 | #
10 |
11 | require "pathname"
12 | ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../../../../../../Gemfile",
13 | Pathname.new(__FILE__).realpath)
14 |
15 | bundle_binstub = File.expand_path("../bundle", __FILE__)
16 |
17 | if File.file?(bundle_binstub)
18 | if File.read(bundle_binstub, 300) =~ /This file was generated by Bundler/
19 | load(bundle_binstub)
20 | else
21 | abort("Your `bin/bundle` was not generated by Bundler, so this binstub cannot run.
22 | Replace `bin/bundle` by running `bundle binstubs bundler --force`, then run this command again.")
23 | end
24 | end
25 |
26 | require "rubygems"
27 | require "bundler/setup"
28 |
29 | load Gem.bin_path("parser", "ruby-rewrite")
30 |
--------------------------------------------------------------------------------
/examples/rails/db/schema.rb:
--------------------------------------------------------------------------------
1 | # frozen_string_literal: true
2 |
3 | # This file is auto-generated from the current state of the database. Instead
4 | # of editing this file, please use the migrations feature of Active Record to
5 | # incrementally modify your database, and then regenerate this schema definition.
6 | #
7 | # This file is the source Rails uses to define your schema when running `bin/rails
8 | # db:schema:load`. When creating a new database, `bin/rails db:schema:load` tends to
9 | # be faster and is potentially less error prone than running all of your
10 | # migrations from scratch. Old migrations may fail to apply correctly if those
11 | # migrations use external dependencies or application code.
12 | #
13 | # It's strongly recommended that you check this file into your version control system.
14 |
15 | ActiveRecord::Schema.define(version: 0) do
16 | # These are extensions that must be enabled in order to support this database
17 | enable_extension 'plpgsql'
18 | end
19 |
--------------------------------------------------------------------------------
/examples/padrino_blog_tutorial/app/frontend/entrypoints/styles.css:
--------------------------------------------------------------------------------
1 | *, ::after, ::before {
2 | box-sizing: border-box;
3 | }
4 |
5 | html {
6 | font-family: ui-sans-serif, system-ui, -apple-system, system-ui, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans", sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol", "Noto Color Emoji";
7 | line-height: 1.5;
8 | }
9 |
10 | body {
11 | font-family: inherit;
12 | line-height: inherit;
13 | margin: 0;
14 | }
15 |
16 | header {
17 | display: grid;
18 | height: 100vh;
19 | margin: 0 auto;
20 | padding-top: 20vh;
21 | place-content: center;
22 | }
23 |
24 | .logo {
25 | height: 0;
26 | opacity: 0;
27 | }
28 |
29 | .banner {
30 | align-items: center;
31 | display: grid;
32 | grid-template-columns: 1fr 1fr;
33 | box-sizing: border-box;
34 | font-size: clamp(4rem, 10vw, 4.5rem);
35 | line-height: 1;
36 | font-weight: 800;
37 | height: 128px;
38 | margin: 0;
39 | text-align: center;
40 | }
41 |
--------------------------------------------------------------------------------
/examples/rails/example_engine/lib/administrator/engine.rb:
--------------------------------------------------------------------------------
1 | # frozen_string_literal: true
2 |
3 | module Administrator
4 | class Engine < ::Rails::Engine
5 | isolate_namespace Administrator
6 | delegate :vite_ruby, to: :class
7 |
8 | def self.vite_ruby
9 | @vite_ruby ||= ViteRuby.new(root: root)
10 | end
11 |
12 | # Expose compiled assets via Rack::Static when running in the host app.
13 | config.app_middleware.use(Rack::Static,
14 | urls: ["/#{ vite_ruby.config.public_output_dir }"],
15 | root: root.join(vite_ruby.config.public_dir))
16 |
17 | initializer 'vite_rails_engine.proxy' do |app|
18 | if vite_ruby.run_proxy?
19 | app.middleware.insert_before 0, ViteRuby::DevServerProxy, ssl_verify_none: true, vite_ruby: vite_ruby
20 | end
21 | end
22 |
23 | initializer 'vite_rails_engine.logger' do
24 | config.after_initialize do
25 | vite_ruby.logger = Rails.logger
26 | end
27 | end
28 | end
29 | end
30 |
--------------------------------------------------------------------------------
/test/test_app/config/application.rb:
--------------------------------------------------------------------------------
1 | # frozen_string_literal: true
2 |
3 | require "action_controller/railtie"
4 | require "action_view/railtie"
5 |
6 | class Rails::Console; end
7 |
8 | if RUBY_VERSION.start_with?("2.4")
9 | require "vite_rails_legacy"
10 | ViteRails = ViteRailsLegacy
11 | else
12 | require "spring/configuration"
13 | Spring.application_root = File.expand_path("..", __dir__)
14 | require "vite_rails"
15 | end
16 |
17 | require "vite_plugin_legacy"
18 |
19 | module TestApp
20 | class Application < ::Rails::Application
21 | config.load_defaults Rails::VERSION::STRING.to_f
22 | config.secret_key_base = SecureRandom.hex
23 | config.eager_load = true
24 | config.active_support.test_order = :sorted
25 |
26 | if Rails.gem_version >= Gem::Version.new("7.0.0")
27 | # Option added in Rails 7.0, defaults to false. Some helper_test tests assume true.
28 | config.action_view.apply_stylesheet_media_default = true
29 | end
30 | end
31 | end
32 |
--------------------------------------------------------------------------------
/test/runner_test.rb:
--------------------------------------------------------------------------------
1 | # frozen_string_literal: true
2 |
3 | require "test_helper"
4 |
5 | class RunnerTest < ViteRuby::Test
6 | def test_dev_server_command
7 | assert_run_command(flags: ["--mode", "production"])
8 | end
9 |
10 | def test_dev_server_command_with_argument
11 | assert_run_command("--quiet", flags: ["--mode", "production"])
12 | end
13 |
14 | def test_build_command
15 | assert_run_command("build", flags: ["--mode", "production"])
16 | end
17 |
18 | def test_build_command_with_argument
19 | with_rails_env("development") do
20 | assert_run_command("build", "--emptyOutDir", flags: ["--mode", "development"])
21 | end
22 | end
23 |
24 | def test_command_capture
25 | ViteRuby::Runner.stub_any_instance(:vite_executable, "echo") {
26 | stdout, stderr, status = ViteRuby.run(['"Hello"'])
27 |
28 | assert_equal %("Hello" --mode production\n), stdout
29 | assert_equal "", stderr
30 | assert status
31 | }
32 | end
33 | end
34 |
--------------------------------------------------------------------------------
/bin/m:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env ruby
2 | # frozen_string_literal: true
3 |
4 | #
5 | # This file was generated by Bundler.
6 | #
7 | # The application 'm' is installed as part of a gem, and
8 | # this file is here to facilitate running it.
9 | #
10 |
11 | require "pathname"
12 | ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../../Gemfile",
13 | Pathname.new(__FILE__).realpath)
14 |
15 | bundle_binstub = File.expand_path("bundle", __dir__)
16 |
17 | if File.file?(bundle_binstub)
18 | if File.read(bundle_binstub, 300).include?("This file was generated by Bundler")
19 | load(bundle_binstub)
20 | else
21 | abort("Your `bin/bundle` was not generated by Bundler, so this binstub cannot run.
22 | Replace `bin/bundle` by running `bundle binstubs bundler --force`, then run this command again.")
23 | end
24 | end
25 |
26 | require "rubygems"
27 | require "bundler/setup"
28 |
29 | ARGV.each_with_index do |arg, index|
30 | ARGV[index] = arg.sub(File.expand_path(Dir.pwd), "")
31 | end
32 |
33 | load Gem.bin_path("m", "m")
34 |
--------------------------------------------------------------------------------
/examples/rails/config/locales/en.yml:
--------------------------------------------------------------------------------
1 | # Files in the config/locales directory are used for internationalization
2 | # and are automatically loaded by Rails. If you want to use locales other
3 | # than English, add the necessary files in this directory.
4 | #
5 | # To use the locales, use `I18n.t`:
6 | #
7 | # I18n.t 'hello'
8 | #
9 | # In views, this is aliased to just `t`:
10 | #
11 | # <%= t('hello') %>
12 | #
13 | # To use a different locale, set it with `I18n.locale`:
14 | #
15 | # I18n.locale = :es
16 | #
17 | # This would use the information in config/locales/es.yml.
18 | #
19 | # The following keys must be escaped otherwise they will not be retrieved by
20 | # the default I18n backend:
21 | #
22 | # true, false, on, off, yes, no
23 | #
24 | # Instead, surround them with single quotes.
25 | #
26 | # en:
27 | # 'true': 'foo'
28 | #
29 | # To learn more, please read the Rails Internationalization guide
30 | # available at https://guides.rubyonrails.org/i18n.html.
31 |
32 | en:
33 | hello: "Hello world"
34 |
--------------------------------------------------------------------------------
/vite_ruby/lib/vite_ruby/cli/ssr.rb:
--------------------------------------------------------------------------------
1 | # frozen_string_literal: true
2 |
3 | class ViteRuby::CLI::SSR < ViteRuby::CLI::Vite
4 | DEFAULT_ENV = CURRENT_ENV || "production"
5 | JS_EXTENSIONS = %w[js mjs cjs]
6 |
7 | desc "Run the resulting app from building in SSR mode."
8 | executable_options
9 |
10 | def call(mode:, inspect: false, trace_deprecation: false)
11 | ViteRuby.env["VITE_RUBY_MODE"] = mode
12 |
13 | ssr_entrypoint = JS_EXTENSIONS
14 | .map { |ext| ViteRuby.config.ssr_output_dir.join("ssr.#{ext}") }
15 | .find(&:exist?)
16 |
17 | raise ArgumentError, "No ssr entrypoint found `#{ViteRuby.config.ssr_output_dir.relative_path_from(ViteRuby.config.root)}/ssr.{#{JS_EXTENSIONS.join(",")}}`. Have you run bin/vite build --ssr?" unless ssr_entrypoint
18 |
19 | cmd = [
20 | "node",
21 | ("--inspect-brk" if inspect),
22 | ("--trace-deprecation" if trace_deprecation),
23 | ssr_entrypoint,
24 | ]
25 | Kernel.exec(*cmd.compact.map(&:to_s))
26 | end
27 | end
28 |
--------------------------------------------------------------------------------
/vite-plugin-ruby/src/constants.ts:
--------------------------------------------------------------------------------
1 | // Internal: Inferred mode, since Vite doesn't yet expose it to its plugins.
2 | export const APP_ENV = process.env.RAILS_ENV || process.env.RACK_ENV || process.env.APP_ENV
3 |
4 | // Internal: Prefix used for environment variables that modify the configuration.
5 | export const ENV_PREFIX = 'VITE_RUBY'
6 |
7 | // Internal: Key of the vite.json file that is applied to all environments.
8 | export const ALL_ENVS_KEY = 'all'
9 |
10 | // Internal: Extensions of CSS files or known precompilers.
11 | export const KNOWN_CSS_EXTENSIONS = [
12 | 'css',
13 | 'less',
14 | 'sass',
15 | 'scss',
16 | 'styl',
17 | 'stylus',
18 | 'pcss',
19 | 'postcss',
20 | ]
21 |
22 | // Internal: Types of files that Vite should process correctly as entrypoints.
23 | export const KNOWN_ENTRYPOINT_TYPES = [
24 | 'html',
25 | 'jsx?',
26 | 'tsx?',
27 | ...KNOWN_CSS_EXTENSIONS,
28 | ]
29 |
30 | export const ENTRYPOINT_TYPES_REGEX = new RegExp(
31 | `\\.(${KNOWN_ENTRYPOINT_TYPES.join('|')})(\\?.*)?$`,
32 | )
33 |
--------------------------------------------------------------------------------
/vite-plugin-rails/example/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "vite-plugin-rails-example",
3 | "version": "0.0.0",
4 | "private": true,
5 | "license": "MIT",
6 | "type": "module",
7 | "scripts": {
8 | "dev": "cross-env DEBUG=vite-plugin-ruby:* vite --open",
9 | "build": "cross-env DEBUG=vite-plugin-ruby:* vite build --mode production --emptyOutDir",
10 | "preview": "cross-env RAILS_ENV=production DEBUG=vite-plugin-ruby:* vite preview --open"
11 | },
12 | "devDependencies": {
13 | "@inertiajs/inertia": "^0.11.1",
14 | "@inertiajs/inertia-vue3": "^0.6.0",
15 | "@inertiajs/server": "^0.1.0",
16 | "@vitejs/plugin-legacy": "^5.0.0",
17 | "@vitejs/plugin-vue": "^4.5.0",
18 | "@vue/server-renderer": "^3.3.8",
19 | "@types/node": "^18",
20 | "cross-env": "^7.0.3",
21 | "sass": "^1.59.3",
22 | "terser": "^5.16.6",
23 | "typescript": "^4.9.5",
24 | "vite": "^5.0.0",
25 | "vite-plugin-rails": "workspace:*",
26 | "vite-plugin-ruby": "workspace:*",
27 | "vue": "^3.3.8"
28 | }
29 | }
30 |
--------------------------------------------------------------------------------
/vite_rails/templates/entrypoints/application.js:
--------------------------------------------------------------------------------
1 | // To see this message, add the following to the `` section in your
2 | // views/layouts/application.html.erb
3 | //
4 | // <%= vite_client_tag %>
5 | // <%= vite_javascript_tag 'application' %>
6 | console.log('Vite ⚡️ Rails')
7 |
8 | // If using a TypeScript entrypoint file:
9 | // <%= vite_typescript_tag 'application' %>
10 | //
11 | // If you want to use .jsx or .tsx, add the extension:
12 | // <%= vite_javascript_tag 'application.jsx' %>
13 |
14 | console.log('Visit the guide for more information: ', 'https://vite-ruby.netlify.app/guide/rails')
15 |
16 | // Example: Load Rails libraries in Vite.
17 | //
18 | // import * as Turbo from '@hotwired/turbo'
19 | // Turbo.start()
20 | //
21 | // import ActiveStorage from '@rails/activestorage'
22 | // ActiveStorage.start()
23 | //
24 | // // Import all channels.
25 | // const channels = import.meta.glob('./**/*_channel.js', { eager: true })
26 |
27 | // Example: Import a stylesheet in app/frontend/index.css
28 | // import '~/index.css'
29 |
--------------------------------------------------------------------------------
/vite_rails_legacy/templates/entrypoints/application.js:
--------------------------------------------------------------------------------
1 | // To see this message, add the following to the `` section in your
2 | // views/layouts/application.html.erb
3 | //
4 | // <%= vite_client_tag %>
5 | // <%= vite_javascript_tag 'application' %>
6 | console.log('Vite ⚡️ Rails')
7 |
8 | // If using a TypeScript entrypoint file:
9 | // <%= vite_typescript_tag 'application' %>
10 | //
11 | // If you want to use .jsx or .tsx, add the extension:
12 | // <%= vite_javascript_tag 'application.jsx' %>
13 |
14 | console.log('Visit the guide for more information: ', 'https://vite-ruby.netlify.app/guide/rails')
15 |
16 | // Example: Load Rails libraries in Vite.
17 | //
18 | // import * as Turbo from '@hotwired/turbo'
19 | // Turbo.start()
20 | //
21 | // import ActiveStorage from '@rails/activestorage'
22 | // ActiveStorage.start()
23 | //
24 | // // Import all channels.
25 | // const channels = import.meta.glob('./**/*_channel.js', { eager: true })
26 |
27 | // Example: Import a stylesheet in app/frontend/index.css
28 | // import '~/index.css'
29 |
--------------------------------------------------------------------------------
/examples/rails/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "blog",
3 | "private": true,
4 | "license": "MIT",
5 | "type": "module",
6 | "scripts": {
7 | "dev": "vite"
8 | },
9 | "engines": {
10 | "node": "18",
11 | "pnpm": "8"
12 | },
13 | "dependencies": {
14 | "@bugsnag/js": "^7.20.2",
15 | "@bugsnag/plugin-react": "^7.19.0",
16 | "@hotwired/turbo": "^7.3.0",
17 | "@rails/actioncable": "^7.0.4",
18 | "@rails/activestorage": "^7.0.4",
19 | "react": "^18.2.0",
20 | "react-dom": "^18.2.0"
21 | },
22 | "version": "0.1.0",
23 | "devDependencies": {
24 | "@types/rails__activestorage": "^7.0.1",
25 | "@vitejs/plugin-legacy": "4.0.3",
26 | "@vitejs/plugin-react": "^4.0.0",
27 | "less": "^4.1.3",
28 | "ms": "^2.1.3",
29 | "sass": "^1.62.1",
30 | "stylus": "^0.54.8",
31 | "terser": "^5.17.1",
32 | "vite": "^4.3.0",
33 | "vite-plugin-bugsnag": "^2.0.2",
34 | "vite-plugin-rails": "^0.1.0",
35 | "vite-plugin-ruby": "^3.2.0",
36 | "vite-plugin-windicss": "^1.8.10"
37 | }
38 | }
39 |
--------------------------------------------------------------------------------
/vite_hanami/vite_hanami.gemspec:
--------------------------------------------------------------------------------
1 | # frozen_string_literal: true
2 |
3 | $LOAD_PATH.push File.expand_path("./lib", __dir__)
4 | require "vite_hanami/version"
5 |
6 | Gem::Specification.new do |s|
7 | s.name = "vite_hanami"
8 | s.version = ViteHanami::VERSION
9 | s.authors = ["Máximo Mussini"]
10 | s.email = ["maximomussini@gmail.com"]
11 | s.summary = "Use Vite in Hanami and bring joy to your JavaScript experience"
12 | s.homepage = "https://github.com/ElMassimo/vite_ruby"
13 | s.license = "MIT"
14 |
15 | s.metadata = {
16 | "source_code_uri" => "https://github.com/ElMassimo/vite_ruby/tree/vite_hanami@#{ViteHanami::VERSION}/vite_hanami",
17 | "changelog_uri" => "https://github.com/ElMassimo/vite_ruby/blob/vite_hanami@#{ViteHanami::VERSION}/vite_hanami/CHANGELOG.md",
18 | "rubygems_mfa_required" => "true",
19 | }
20 |
21 | s.required_ruby_version = Gem::Requirement.new(">= 2.5")
22 |
23 | s.add_dependency "vite_ruby", "~> 3.0"
24 |
25 | s.files = Dir.glob("{lib,templates}/**/*") + %w[README.md CHANGELOG.md LICENSE.txt]
26 | end
27 |
--------------------------------------------------------------------------------
/vite_padrino/vite_padrino.gemspec:
--------------------------------------------------------------------------------
1 | # frozen_string_literal: true
2 |
3 | $LOAD_PATH.push File.expand_path("./lib", __dir__)
4 | require "vite_padrino/version"
5 |
6 | Gem::Specification.new do |s|
7 | s.name = "vite_padrino"
8 | s.version = VitePadrino::VERSION
9 | s.authors = ["Máximo Mussini"]
10 | s.email = ["maximomussini@gmail.com"]
11 | s.summary = "Use Vite in Padrino and bring joy to your JavaScript experience"
12 | s.homepage = "https://github.com/ElMassimo/vite_ruby"
13 | s.license = "MIT"
14 |
15 | s.metadata = {
16 | "source_code_uri" => "https://github.com/ElMassimo/vite_ruby/tree/vite_padrino@#{VitePadrino::VERSION}/vite_padrino",
17 | "changelog_uri" => "https://github.com/ElMassimo/vite_ruby/blob/vite_padrino@#{VitePadrino::VERSION}/vite_padrino/CHANGELOG.md",
18 | "rubygems_mfa_required" => "true",
19 | }
20 |
21 | s.required_ruby_version = Gem::Requirement.new(">= 2.5")
22 |
23 | s.add_dependency "vite_ruby", "~> 3.0"
24 |
25 | s.files = Dir.glob("{lib,templates}/**/*") + %w[README.md CHANGELOG.md LICENSE.txt]
26 | end
27 |
--------------------------------------------------------------------------------
/examples/rails/spec/support/capybara.rb:
--------------------------------------------------------------------------------
1 | # frozen_string_literal: true
2 |
3 | require 'capybara/cuprite'
4 |
5 | Capybara.register_driver(:cuprite) do |app, _options|
6 | cuprite_timeout = ENV.fetch('CUPRITE_TIMEOUT', 30).to_i
7 |
8 | Capybara::Cuprite::Driver.new(
9 | app,
10 | js_errors: true,
11 | browser_options: {
12 | 'disable-infobars' => nil,
13 | 'no-sandbox' => nil,
14 | 'disable-dev-shm-usage' => nil,
15 | 'disable-site-isolation-trials' => nil,
16 | },
17 | timeout: cuprite_timeout,
18 | process_timeout: cuprite_timeout,
19 | inspector: !ENV['CI'],
20 | headless: %w[true 1 yes].include?(ENV['HEADLESS'] || ENV['CI']),
21 | slowmo: ENV['SLOWMO'] == 'true' ? 0.1 : ENV['SLOWMO'],
22 | )
23 | end
24 |
25 | Capybara.configure do |config|
26 | config.default_driver = :cuprite
27 | config.javascript_driver = :cuprite
28 |
29 | config.match = :smart
30 | config.exact = true
31 | config.ignore_hidden_elements = true
32 | config.default_max_wait_time = 3
33 | config.default_normalize_ws = true
34 | end
35 |
--------------------------------------------------------------------------------
/scripts/verifyCommit.cjs:
--------------------------------------------------------------------------------
1 | /* eslint-disable @typescript-eslint/no-var-requires */
2 | /* eslint-disable import/order */
3 | const args = require('minimist')(process.argv.slice(2))
4 | const msgPath = args._[0]
5 | const msg = require('fs').readFileSync(msgPath, 'utf-8').trim()
6 |
7 | const releaseRE = /^v\d/
8 | const commitRE = /^(revert: )?(feat|fix|docs|dx|refactor|perf|test|workflow|build|ci|chore|types|wip|release|deps)(\(.+\))?: .{1,50}/
9 |
10 | if (!releaseRE.test(msg) && !commitRE.test(msg)) {
11 | console.log()
12 | const chalk = require('chalk')
13 | console.error(
14 | ` ${chalk.bgRed.white(' ERROR ')} ${chalk.red(
15 | 'invalid commit message format.',
16 | )}\n\n${
17 | chalk.red(
18 | ' Proper commit message format is required for automated changelog generation. Examples:\n\n',
19 | )
20 | } ${chalk.green('feat: add \'comments\' option')}\n`
21 | + ` ${chalk.green('fix: handle events on blur (close #28)')}\n\n${
22 | chalk.red(' See .github/commit-convention.md for more details.\n')}`,
23 | )
24 | process.exit(1)
25 | }
26 |
--------------------------------------------------------------------------------
/examples/rails/.gitignore:
--------------------------------------------------------------------------------
1 | # See https://help.github.com/articles/ignoring-files for more about ignoring files.
2 | #
3 | # If you find yourself ignoring temporary files generated by your text editor
4 | # or operating system, you probably want to add a global ignore instead:
5 | # git config --global core.excludesfile '~/.gitignore_global'
6 |
7 | # Ignore bundler config.
8 | /.bundle
9 |
10 | # Ignore the default SQLite database.
11 | /db/*.sqlite3
12 | /db/*.sqlite3-journal
13 | /db/*.sqlite3-*
14 |
15 | # Ignore all logfiles and tempfiles.
16 | /log/*
17 | /tmp/*
18 | !/log/.keep
19 | !/tmp/.keep
20 |
21 | # Ignore pidfiles, but keep the directory.
22 | /tmp/pids/*
23 | !/tmp/pids/
24 | !/tmp/pids/.keep
25 |
26 | # Ignore uploaded files in development.
27 | /storage/*
28 | !/storage/.keep
29 |
30 | /public/assets
31 | .byebug_history
32 |
33 | # Ignore master key for decrypting credentials and more.
34 | /config/master.key
35 |
36 | /public/packs
37 | /public/packs-test
38 | /node_modules
39 | /yarn-error.log
40 | yarn-debug.log*
41 | .yarn-integrity
42 |
43 | # Vite Ruby
44 | /public/vite*
45 | node_modules
46 | *.local
47 | .DS_Store
48 |
--------------------------------------------------------------------------------
/examples/rails/example_engine/administrator.gemspec:
--------------------------------------------------------------------------------
1 | require_relative "lib/administrator/version"
2 |
3 | Gem::Specification.new do |spec|
4 | spec.name = "administrator"
5 | spec.version = Administrator::VERSION
6 | spec.authors = ["Maximo Mussini"]
7 | spec.email = ["maximomussini@gmail.com"]
8 | spec.homepage = "https://github.com/ElMassimo/vite_ruby/tree/main/examples/example_engine"
9 | spec.summary = "Example of how to use Vite Ruby inside a Rails engine"
10 | spec.license = "MIT"
11 |
12 | # Prevent pushing this gem to RubyGems.org. To allow pushes either set the 'allowed_push_host'
13 | # to allow pushing to a single host or delete this section to allow pushing to any host.
14 | spec.metadata["allowed_push_host"] = "TODO: Set to 'http://mygemserver.com'"
15 |
16 | spec.metadata["homepage_uri"] = spec.homepage
17 | spec.metadata["source_code_uri"] = spec.homepage
18 |
19 | spec.files = Dir["{app,config,db,lib}/**/*", "MIT-LICENSE", "Rakefile", "README.md"]
20 |
21 | spec.add_dependency "rails"
22 | spec.add_dependency "vite_rails"
23 | spec.add_dependency "bootsnap"
24 | end
25 |
--------------------------------------------------------------------------------
/vite_plugin_legacy/vite_plugin_legacy.gemspec:
--------------------------------------------------------------------------------
1 | # frozen_string_literal: true
2 |
3 | $LOAD_PATH.push File.expand_path("./lib", __dir__)
4 | require "vite_plugin_legacy/version"
5 |
6 | Gem::Specification.new do |s|
7 | s.name = "vite_plugin_legacy"
8 | s.version = VitePluginLegacy::VERSION
9 | s.authors = ["Máximo Mussini"]
10 | s.email = ["maximomussini@gmail.com"]
11 | s.summary = "Tag helpers for @vitejs/plugin-legacy to support legacy browsers"
12 | s.homepage = "https://github.com/ElMassimo/vite_ruby"
13 | s.license = "MIT"
14 |
15 | s.metadata = {
16 | "source_code_uri" => "https://github.com/ElMassimo/vite_ruby/tree/vite_plugin_legacy@#{VitePluginLegacy::VERSION}/vite_plugin_legacy",
17 | "changelog_uri" => "https://github.com/ElMassimo/vite_ruby/blob/vite_plugin_legacy@#{VitePluginLegacy::VERSION}/vite_plugin_legacy/CHANGELOG.md",
18 | "rubygems_mfa_required" => "true",
19 | }
20 |
21 | s.required_ruby_version = Gem::Requirement.new(">= 2.4")
22 |
23 | s.add_dependency "vite_ruby", "~> 3.0", ">= 3.0.4"
24 |
25 | s.files = Dir.glob("{lib,templates}/**/*") + %w[README.md CHANGELOG.md LICENSE.txt]
26 | end
27 |
--------------------------------------------------------------------------------
/vite_padrino/lib/vite_padrino/installation.rb:
--------------------------------------------------------------------------------
1 | # frozen_string_literal: true
2 |
3 | require "vite_padrino"
4 |
5 | # Internal: Extends the base installation script from Vite Ruby to work for a
6 | # typical Padrino app.
7 | module VitePadrino::Installation
8 | PADRINO_TEMPLATES = Pathname.new(File.expand_path("../../templates", __dir__))
9 |
10 | # Override: Setup a typical apps/web Padrino app to use Vite.
11 | def setup_app_files
12 | cp PADRINO_TEMPLATES.join("config/padrino-vite.json"), config.config_path
13 | inject_line_after root.join("app/app.rb"), "register", " register VitePadrino"
14 | append root.join("Rakefile"), <<~RAKE
15 | require 'vite_padrino'
16 | ViteRuby.install_tasks
17 | RAKE
18 | end
19 |
20 | # Override: Inject the vite client and sample script to the default HTML template.
21 | def install_sample_files
22 | super
23 | inject_line_after root.join("app/views/layouts/application.haml"), "%title", <<-HTML
24 | = vite_client_tag
25 | = vite_javascript_tag 'application'
26 | HTML
27 | end
28 | end
29 |
30 | ViteRuby::CLI::Install.prepend(VitePadrino::Installation)
31 |
--------------------------------------------------------------------------------
/vite_ruby/lib/vite_ruby/io.rb:
--------------------------------------------------------------------------------
1 | # frozen_string_literal: true
2 |
3 | require "open3"
4 |
5 | # Public: Builds on top of Ruby I/O open3 providing a friendlier experience.
6 | module ViteRuby::IO
7 | class << self
8 | # Internal: A modified version of capture3 that can continuosly print stdout.
9 | # NOTE: Streaming output provides a better UX when running bin/vite build.
10 | def capture(*cmd, with_output: $stdout.method(:puts), stdin_data: "", **opts)
11 | return Open3.capture3(*cmd, **opts) unless with_output
12 |
13 | Open3.popen3(*cmd, **opts) { |stdin, stdout, stderr, wait_threads|
14 | stdin << stdin_data
15 | stdin.close
16 | out = Thread.new { read_lines(stdout, &with_output) }
17 | err = Thread.new { stderr.read }
18 | [out.value, err.value.to_s, wait_threads.value]
19 | }
20 | end
21 |
22 | # Internal: Reads and yield every line in the stream. Returns the full content.
23 | def read_lines(io)
24 | buffer = +""
25 | while line = io.gets
26 | buffer << line
27 | yield line
28 | end
29 | buffer
30 | end
31 | end
32 | end
33 |
--------------------------------------------------------------------------------
/LICENSE.txt:
--------------------------------------------------------------------------------
1 | The MIT License (MIT)
2 |
3 | Copyright (c) 2020 Maximo Mussini
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in
13 | all copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21 | THE SOFTWARE.
22 |
--------------------------------------------------------------------------------
/examples/rails/example_engine/MIT-LICENSE:
--------------------------------------------------------------------------------
1 | Copyright 2021 Maximo Mussini
2 |
3 | Permission is hereby granted, free of charge, to any person obtaining
4 | a copy of this software and associated documentation files (the
5 | "Software"), to deal in the Software without restriction, including
6 | without limitation the rights to use, copy, modify, merge, publish,
7 | distribute, sublicense, and/or sell copies of the Software, and to
8 | permit persons to whom the Software is furnished to do so, subject to
9 | the following conditions:
10 |
11 | The above copyright notice and this permission notice shall be
12 | included in all copies or substantial portions of the Software.
13 |
14 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17 | NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18 | LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19 | OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20 | WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
21 |
--------------------------------------------------------------------------------
/vite_rails_legacy/lib/vite_rails_legacy/engine.rb:
--------------------------------------------------------------------------------
1 | # frozen_string_literal: true
2 |
3 | require "rails/railtie"
4 |
5 | class ViteRailsLegacy::Engine < Rails::Engine
6 | initializer "vite_rails.proxy" do |app|
7 | app.middleware.insert_before 0, "ViteRuby::DevServerProxy", ssl_verify_none: true if ViteRuby.run_proxy?
8 | end
9 |
10 | initializer "vite_rails_legacy.helper" do
11 | ActiveSupport.on_load(:action_controller) do
12 | ActionController::Base.helper(ViteRailsLegacy::TagHelpers)
13 | end
14 |
15 | ActiveSupport.on_load(:action_view) do
16 | include ViteRailsLegacy::TagHelpers
17 | end
18 | end
19 |
20 | initializer "vite_rails.logger" do
21 | config.after_initialize do
22 | ViteRuby.instance.logger = Rails.logger
23 | end
24 | end
25 |
26 | initializer "vite_rails.bootstrap" do
27 | if defined?(Rails::Server) || defined?(Rails::Console)
28 | ViteRuby.bootstrap
29 | if defined?(Spring)
30 | require "spring/watcher"
31 | Spring.after_fork { ViteRuby.bootstrap }
32 | Spring.watch(ViteRuby.config.config_path)
33 | end
34 | end
35 | end
36 | end
37 |
--------------------------------------------------------------------------------
/vite_rails_legacy/vite_rails_legacy.gemspec:
--------------------------------------------------------------------------------
1 | # frozen_string_literal: true
2 |
3 | $LOAD_PATH.push File.expand_path("./lib", __dir__)
4 | require "vite_rails_legacy/version"
5 |
6 | Gem::Specification.new do |s|
7 | s.name = "vite_rails_legacy"
8 | s.version = ViteRailsLegacy::VERSION
9 | s.authors = ["Máximo Mussini"]
10 | s.email = ["maximomussini@gmail.com"]
11 | s.summary = "Use Vite in Rails 4 and bring joy to your JavaScript experience"
12 | s.homepage = "https://github.com/ElMassimo/vite_ruby"
13 | s.license = "MIT"
14 |
15 | s.metadata = {
16 | "source_code_uri" => "https://github.com/ElMassimo/vite_ruby/tree/vite_rails_legacy@#{ViteRailsLegacy::VERSION}/vite_rails_legacy",
17 | "changelog_uri" => "https://github.com/ElMassimo/vite_ruby/blob/vite_rails_legacy@#{ViteRailsLegacy::VERSION}/vite_rails_legacy/CHANGELOG.md",
18 | "rubygems_mfa_required" => "true",
19 | }
20 |
21 | s.required_ruby_version = Gem::Requirement.new(">= 2.4")
22 |
23 | s.add_dependency "railties", "< 5"
24 | s.add_dependency "vite_ruby", "~> 3.0"
25 |
26 | s.files = Dir.glob("{lib,templates}/**/*") + %w[README.md CHANGELOG.md LICENSE.txt]
27 | end
28 |
--------------------------------------------------------------------------------
/vite_rails/vite_rails.gemspec:
--------------------------------------------------------------------------------
1 | # frozen_string_literal: true
2 |
3 | $LOAD_PATH.push File.expand_path("./lib", __dir__)
4 | require "vite_rails/version"
5 |
6 | Gem::Specification.new do |s|
7 | s.name = "vite_rails"
8 | s.version = ViteRails::VERSION
9 | s.authors = ["Máximo Mussini"]
10 | s.email = ["maximomussini@gmail.com"]
11 | s.summary = "Use Vite in Rails and bring joy to your JavaScript experience"
12 | s.homepage = "https://github.com/ElMassimo/vite_ruby"
13 | s.license = "MIT"
14 |
15 | s.metadata = {
16 | "source_code_uri" => "https://github.com/ElMassimo/vite_ruby/tree/vite_rails@#{ViteRails::VERSION}/vite_rails",
17 | "changelog_uri" => "https://github.com/ElMassimo/vite_ruby/blob/vite_rails@#{ViteRails::VERSION}/vite_rails/CHANGELOG.md",
18 | "rubygems_mfa_required" => "true",
19 | }
20 |
21 | s.required_ruby_version = Gem::Requirement.new(">= 2.5")
22 |
23 | s.add_dependency "railties", ">= 5.1", "< 9"
24 | s.add_dependency "vite_ruby", ">= 3.2.2", "~> 3.0"
25 |
26 | s.add_development_dependency "spring", "~> 2.1"
27 |
28 | s.files = Dir.glob("{lib,templates}/**/*") + %w[README.md CHANGELOG.md LICENSE.txt]
29 | end
30 |
--------------------------------------------------------------------------------
/vite_ruby/LICENSE.txt:
--------------------------------------------------------------------------------
1 | The MIT License (MIT)
2 |
3 | Copyright (c) 2020 Maximo Mussini
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in
13 | all copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21 | THE SOFTWARE.
22 |
--------------------------------------------------------------------------------
/vite_hanami/LICENSE.txt:
--------------------------------------------------------------------------------
1 | The MIT License (MIT)
2 |
3 | Copyright (c) 2020 Maximo Mussini
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in
13 | all copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21 | THE SOFTWARE.
22 |
--------------------------------------------------------------------------------
/vite_padrino/LICENSE.txt:
--------------------------------------------------------------------------------
1 | The MIT License (MIT)
2 |
3 | Copyright (c) 2021 Maximo Mussini
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in
13 | all copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21 | THE SOFTWARE.
22 |
--------------------------------------------------------------------------------
/vite_rails/LICENSE.txt:
--------------------------------------------------------------------------------
1 | The MIT License (MIT)
2 |
3 | Copyright (c) 2020 Maximo Mussini
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in
13 | all copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21 | THE SOFTWARE.
22 |
--------------------------------------------------------------------------------
/vite-plugin-rails/LICENSE.txt:
--------------------------------------------------------------------------------
1 | The MIT License (MIT)
2 |
3 | Copyright (c) 2022 Maximo Mussini
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in
13 | all copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21 | THE SOFTWARE.
22 |
--------------------------------------------------------------------------------
/vite-plugin-ruby/LICENSE.txt:
--------------------------------------------------------------------------------
1 | The MIT License (MIT)
2 |
3 | Copyright (c) 2020 Maximo Mussini
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in
13 | all copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21 | THE SOFTWARE.
22 |
--------------------------------------------------------------------------------
/vite_plugin_legacy/LICENSE.txt:
--------------------------------------------------------------------------------
1 | The MIT License (MIT)
2 |
3 | Copyright (c) 2021 Maximo Mussini
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in
13 | all copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21 | THE SOFTWARE.
22 |
--------------------------------------------------------------------------------
/vite_rails_legacy/LICENSE.txt:
--------------------------------------------------------------------------------
1 | The MIT License (MIT)
2 |
3 | Copyright (c) 2020 Maximo Mussini
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in
13 | all copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21 | THE SOFTWARE.
22 |
--------------------------------------------------------------------------------
/examples/rails/example_engine/README.md:
--------------------------------------------------------------------------------
1 | # Vite Ruby ➕ Rails Engine
2 |
3 | An example on how to configure a Rails engine to use Vite Ruby.
4 |
5 | ## Configuration ⚙️
6 |
7 | - Add `vite_rails` as a dependency in the engine `gemspec`
8 | - Run `bundle install` and `bundle exec vite install` in the engine directory
9 | - Check that the following files were added and configure them:
10 | - `config/vite.json`: Use a different `publicOutputDir` and `development.port` than the parent application to avoid conflicts
11 | - `vite.config.ts`: Should be using `vite-plugin-ruby`
12 |
13 | See `engine.rb` and ` application_helper.rb` in this example to add the rest
14 | of the setup.
15 |
16 | The `vite_manifest` must be overriden in the engine view helpers.
17 |
18 | ## Development 💻
19 |
20 | In order to enable HMR for assets inside the engine, run `bin/vite` inside the
21 | engine directory, and make sure you are rendering `vite_client_tag` in your
22 | engine views.
23 |
24 | Use a different `development.port` to prevent connecting to the same Vite dev
25 | server as the parent app.
26 |
27 | ## Deployment 🚀
28 |
29 | Run `bin/vite build` inside the engine directory to precompile assets.
30 |
--------------------------------------------------------------------------------
/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "vite_ruby_monorepo",
3 | "version": "1.0.0",
4 | "private": true,
5 | "license": "MIT",
6 | "type": "module",
7 | "scripts": {
8 | "docs": "npm -C docs run dev",
9 | "docs:search": "npm -C docs run search",
10 | "release": "node scripts/release.cjs",
11 | "lint": "lint-staged",
12 | "postinstall": "husky install",
13 | "changelog": "node scripts/changelog.cjs"
14 | },
15 | "devDependencies": {
16 | "@mussi/eslint-config": "^0.5.1",
17 | "@types/node": "^18",
18 | "chalk": "^4.1.2",
19 | "conventional-changelog-cli": "^2.2.2",
20 | "enquirer": "^2.3.6",
21 | "eslint": "^7.32.0",
22 | "execa": "^5.1.1",
23 | "husky": "^5.2.0",
24 | "lint-staged": "^10.5.4",
25 | "minimist": "^1.2.6",
26 | "semver": "^7.3.7",
27 | "typescript": "^4.7.4"
28 | },
29 | "lint-staged": {
30 | "*.{js,ts,tsx,jsx,vue}": [
31 | "eslint --fix"
32 | ],
33 | "*.rb": [
34 | "bin/rubocop -A"
35 | ]
36 | },
37 | "repository": {
38 | "type": "git",
39 | "url": "https://github.com/ElMassimo/vite_ruby"
40 | },
41 | "homepage": "https://github.com/ElMassimo/vite_ruby"
42 | }
43 |
--------------------------------------------------------------------------------
/vite-plugin-ruby/LICENSE:
--------------------------------------------------------------------------------
1 | MIT License
2 |
3 | Copyright (c) 2021 Maximo Mussini
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
22 |
--------------------------------------------------------------------------------