How to import JS files with esbuild & jsbundling-rails
I'm moving a Rails 6 app from webpack & webpacker to esbuild & jsbundling-rails
I can't find any documentation on the correct way to import custom js files in application.js, if not using stimulus. Thanks.
1 answer
-
answered 2022-04-29 10:46
Joe Thor
Verifying Set Up
Once the jsbundling-rails gem is added to the Gemfile
gem "jsbundling-rails"
and installed (see the documentation on the repo for installation), you may need to start the javascript watcher with the commandyarn build --watch
.Adding Custom JavaScript
You can add custom JavaScript to the /app/javascript directory and then link it on the application.js. Once the custom javascript is added, the bundler should compile the new fingerprinted javascript file in the /app/assets/build directory.
Example
Adding
new.js
to the /app/javascript//new.js alert('hit')
Linking new.js on the application.js
//application.js // Entry point for the build script in your package.json import "@hotwired/turbo-rails" // import "./controllers" import * as bootstrap from "bootstrap" import './new.js'
In the terminal which started the watcher, after the new javascript is saved it outputs
[watch] build started (change: "app/javascript/application.js") [watch] build finished
And there is now the following files in /app/assets/build
//new.js (() => { // app/javascript/new.js alert("hit"); })(); //# sourceMappingURL=new.js.map
//new.js.map { "version": 3, "sources": ["../../javascript/new.js"], "sourcesContent": ["alert('hit')"], "mappings": ";;AAAA,QAAM;", "names": [] }
do you know?
how many words do you know
See also questions close to this topic
-
problems to run rails s on Rails 4 :S
Im trying to run s on my project in Rails 4.2.2
but i get a unexpected error :S
Someone know the reason of the error?
Thanks in advance This is my logs .................................................................................................................................................................................................➜ backend-ror git:(dev) ✗ rails s => Booting Puma => Rails 4.2.2 application starting in development on http://localhost:3000 => Run `rails server -h` for more startup options => Ctrl-C to shutdown server Expected string default value for '--jbuilder'; got true (boolean) Expected string default value for '--serializer'; got true (boolean) Exiting /Users/Cristopheer96/code/Cristopheer96/Guudjob/backend-ror/vendor/cache/ruby/2.3.0/gems/activesupport-4.2.2/lib/active_support/dependencies.rb:457:in `load': /Users/Cristopheer96/code/Cristopheer96/Guudjob/backend-ror/app/controllers/application_controller.rb:39: syntax error, unexpected tIDENTIFIER, expecting keyword_then or ',' or ';' or '\n' (SyntaxError) from /Users/Cristopheer96/code/Cristopheer96/Guudjob/backend-ror/vendor/cache/ruby/2.3.0/gems/activesupport-4.2.2/lib/active_support/dependencies.rb:457:in `block in load_file' from /Users/Cristopheer96/code/Cristopheer96/Guudjob/backend-ror/vendor/cache/ruby/2.3.0/gems/activesupport-4.2.2/lib/active_support/dependencies.rb:647:in `new_constants_in' from /Users/Cristopheer96/code/Cristopheer96/Guudjob/backend-ror/vendor/cache/ruby/2.3.0/gems/activesupport-4.2.2/lib/active_support/dependencies.rb:456:in `load_file' from /Users/Cristopheer96/code/Cristopheer96/Guudjob/backend-ror/vendor/cache/ruby/2.3.0/gems/activesupport-4.2.2/lib/active_support/dependencies.rb:354:in `require_or_load' from /Users/Cristopheer96/code/Cristopheer96/Guudjob/backend-ror/vendor/cache/ruby/2.3.0/gems/activesupport-4.2.2/lib/active_support/dependencies.rb:494:in `load_missing_constant' from /Users/Cristopheer96/code/Cristopheer96/Guudjob/backend-ror/vendor/cache/ruby/2.3.0/gems/activesupport-4.2.2/lib/active_support/dependencies.rb:184:in `const_missing' from /Users/Cristopheer96/code/Cristopheer96/Guudjob/backend-ror/vendor/cache/ruby/2.3.0/gems/inherited_resources-1.9.0/app/controllers/inherited_resources/base.rb:11:in `<module:InheritedResources>' from /Users/Cristopheer96/code/Cristopheer96/Guudjob/backend-ror/vendor/cache/ruby/2.3.0/gems/inherited_resources-1.9.0/app/controllers/inherited_resources/base.rb:1:in `<top (required)>' from /Users/Cristopheer96/code/Cristopheer96/Guudjob/backend-ror/vendor/cache/ruby/2.3.0/gems/activesupport-4.2.2/lib/active_support/dependencies.rb:457:in `load' from /Users/Cristopheer96/code/Cristopheer96/Guudjob/backend-ror/vendor/cache/ruby/2.3.0/gems/activesupport-4.2.2/lib/active_support/dependencies.rb:457:in `block in load_file' from /Users/Cristopheer96/code/Cristopheer96/Guudjob/backend-ror/vendor/cache/ruby/2.3.0/gems/activesupport-4.2.2/lib/active_support/dependencies.rb:647:in `new_constants_in' from /Users/Cristopheer96/code/Cristopheer96/Guudjob/backend-ror/vendor/cache/ruby/2.3.0/gems/activesupport-4.2.2/lib/active_support/dependencies.rb:456:in `load_file' from /Users/Cristopheer96/code/Cristopheer96/Guudjob/backend-ror/vendor/cache/ruby/2.3.0/gems/activesupport-4.2.2/lib/active_support/dependencies.rb:354:in `require_or_load' from /Users/Cristopheer96/code/Cristopheer96/Guudjob/backend-ror/vendor/cache/ruby/2.3.0/gems/activesupport-4.2.2/lib/active_support/dependencies.rb:494:in `load_missing_constant' from /Users/Cristopheer96/code/Cristopheer96/Guudjob/backend-ror/vendor/cache/ruby/2.3.0/gems/activesupport-4.2.2/lib/active_support/dependencies.rb:184:in `const_missing' from /Users/Cristopheer96/code/Cristopheer96/Guudjob/backend-ror/vendor/cache/ruby/2.3.0/gems/activeadmin-1.4.3/lib/active_admin/base_controller/authorization.rb:2:in `<module:ActiveAdmin>' from /Users/Cristopheer96/code/Cristopheer96/Guudjob/backend-ror/vendor/cache/ruby/2.3.0/gems/activeadmin-1.4.3/lib/active_admin/base_controller/authorization.rb:1:in `<top (required)>' from /Users/Cristopheer96/code/Cristopheer96/Guudjob/backend-ror/vendor/cache/ruby/2.3.0/gems/activesupport-4.2.2/lib/active_support/dependencies.rb:274:in `require' from /Users/Cristopheer96/code/Cristopheer96/Guudjob/backend-ror/vendor/cache/ruby/2.3.0/gems/activesupport-4.2.2/lib/active_support/dependencies.rb:274:in `block in require' from /Users/Cristopheer96/code/Cristopheer96/Guudjob/backend-ror/vendor/cache/ruby/2.3.0/gems/activesupport-4.2.2/lib/active_support/dependencies.rb:240:in `load_dependency' from /Users/Cristopheer96/code/Cristopheer96/Guudjob/backend-ror/vendor/cache/ruby/2.3.0/gems/activesupport-4.2.2/lib/active_support/dependencies.rb:274:in `require' from /Users/Cristopheer96/code/Cristopheer96/Guudjob/backend-ror/vendor/cache/ruby/2.3.0/gems/activeadmin-1.4.3/lib/active_admin/base_controller.rb:1:in `<top (required)>' from /Users/Cristopheer96/code/Cristopheer96/Guudjob/backend-ror/vendor/cache/ruby/2.3.0/gems/activesupport-4.2.2/lib/active_support/dependencies.rb:274:in `require' from /Users/Cristopheer96/code/Cristopheer96/Guudjob/backend-ror/vendor/cache/ruby/2.3.0/gems/activesupport-4.2.2/lib/active_support/dependencies.rb:274:in `block in require' from /Users/Cristopheer96/code/Cristopheer96/Guudjob/backend-ror/vendor/cache/ruby/2.3.0/gems/activesupport-4.2.2/lib/active_support/dependencies.rb:240:in `load_dependency' from /Users/Cristopheer96/code/Cristopheer96/Guudjob/backend-ror/vendor/cache/ruby/2.3.0/gems/activesupport-4.2.2/lib/active_support/dependencies.rb:274:in `require' from /Users/Cristopheer96/code/Cristopheer96/Guudjob/backend-ror/vendor/cache/ruby/2.3.0/gems/activeadmin-1.4.3/lib/active_admin/application.rb:166:in `controllers_for_filters' from /Users/Cristopheer96/code/Cristopheer96/Guudjob/backend-ror/vendor/cache/ruby/2.3.0/gems/activeadmin-1.4.3/lib/active_admin/application.rb:159:in `block (2 levels) in <class:Application>' from /Users/Cristopheer96/code/Cristopheer96/Guudjob/backend-ror/config/initializers/active_admin.rb:12:in `block in <top (required)>' from /Users/Cristopheer96/code/Cristopheer96/Guudjob/backend-ror/vendor/cache/ruby/2.3.0/gems/activeadmin-1.4.3/lib/active_admin.rb:69:in `setup' from /Users/Cristopheer96/code/Cristopheer96/Guudjob/backend-ror/config/initializers/active_admin.rb:1:in `<top (required)>' from /Users/Cristopheer96/code/Cristopheer96/Guudjob/backend-ror/vendor/cache/ruby/2.3.0/gems/activesupport-4.2.2/lib/active_support/dependencies.rb:268:in `load' from /Users/Cristopheer96/code/Cristopheer96/Guudjob/backend-ror/vendor/cache/ruby/2.3.0/gems/activesupport-4.2.2/lib/active_support/dependencies.rb:268:in `block in load' from /Users/Cristopheer96/code/Cristopheer96/Guudjob/backend-ror/vendor/cache/ruby/2.3.0/gems/activesupport-4.2.2/lib/active_support/dependencies.rb:240:in `load_dependency' from /Users/Cristopheer96/code/Cristopheer96/Guudjob/backend-ror/vendor/cache/ruby/2.3.0/gems/activesupport-4.2.2/lib/active_support/dependencies.rb:268:in `load' from /Users/Cristopheer96/code/Cristopheer96/Guudjob/backend-ror/vendor/cache/ruby/2.3.0/gems/railties-4.2.2/lib/rails/engine.rb:652:in `block in load_config_initializer' from /Users/Cristopheer96/code/Cristopheer96/Guudjob/backend-ror/vendor/cache/ruby/2.3.0/gems/activesupport-4.2.2/lib/active_support/notifications.rb:166:in `instrument' from /Users/Cristopheer96/code/Cristopheer96/Guudjob/backend-ror/vendor/cache/ruby/2.3.0/gems/railties-4.2.2/lib/rails/engine.rb:651:in `load_config_initializer' from /Users/Cristopheer96/code/Cristopheer96/Guudjob/backend-ror/vendor/cache/ruby/2.3.0/gems/railties-4.2.2/lib/rails/engine.rb:616:in `block (2 levels) in <class:Engine>' from /Users/Cristopheer96/code/Cristopheer96/Guudjob/backend-ror/vendor/cache/ruby/2.3.0/gems/railties-4.2.2/lib/rails/engine.rb:615:in `each' from /Users/Cristopheer96/code/Cristopheer96/Guudjob/backend-ror/vendor/cache/ruby/2.3.0/gems/railties-4.2.2/lib/rails/engine.rb:615:in `block in <class:Engine>' from /Users/Cristopheer96/code/Cristopheer96/Guudjob/backend-ror/vendor/cache/ruby/2.3.0/gems/railties-4.2.2/lib/rails/initializable.rb:30:in `instance_exec' from /Users/Cristopheer96/code/Cristopheer96/Guudjob/backend-ror/vendor/cache/ruby/2.3.0/gems/railties-4.2.2/lib/rails/initializable.rb:30:in `run' from /Users/Cristopheer96/code/Cristopheer96/Guudjob/backend-ror/vendor/cache/ruby/2.3.0/gems/railties-4.2.2/lib/rails/initializable.rb:55:in `block in run_initializers' from /Users/Cristopheer96/.rbenv/versions/2.3.1/lib/ruby/2.3.0/tsort.rb:228:in `block in tsort_each' from /Users/Cristopheer96/.rbenv/versions/2.3.1/lib/ruby/2.3.0/tsort.rb:350:in `block (2 levels) in each_strongly_connected_component' from /Users/Cristopheer96/.rbenv/versions/2.3.1/lib/ruby/2.3.0/tsort.rb:422:in `block (2 levels) in each_strongly_connected_component_from' from /Users/Cristopheer96/.rbenv/versions/2.3.1/lib/ruby/2.3.0/tsort.rb:431:in `each_strongly_connected_component_from' from /Users/Cristopheer96/.rbenv/versions/2.3.1/lib/ruby/2.3.0/tsort.rb:421:in `block in each_strongly_connected_component_from' from /Users/Cristopheer96/code/Cristopheer96/Guudjob/backend-ror/vendor/cache/ruby/2.3.0/gems/railties-4.2.2/lib/rails/initializable.rb:44:in `each' from /Users/Cristopheer96/code/Cristopheer96/Guudjob/backend-ror/vendor/cache/ruby/2.3.0/gems/railties-4.2.2/lib/rails/initializable.rb:44:in `tsort_each_child' from /Users/Cristopheer96/.rbenv/versions/2.3.1/lib/ruby/2.3.0/tsort.rb:415:in `call' from /Users/Cristopheer96/.rbenv/versions/2.3.1/lib/ruby/2.3.0/tsort.rb:415:in `each_strongly_connected_component_from' from /Users/Cristopheer96/.rbenv/versions/2.3.1/lib/ruby/2.3.0/tsort.rb:349:in `block in each_strongly_connected_component' from /Users/Cristopheer96/.rbenv/versions/2.3.1/lib/ruby/2.3.0/tsort.rb:347:in `each' from /Users/Cristopheer96/.rbenv/versions/2.3.1/lib/ruby/2.3.0/tsort.rb:347:in `call' from /Users/Cristopheer96/.rbenv/versions/2.3.1/lib/ruby/2.3.0/tsort.rb:347:in `each_strongly_connected_component' from /Users/Cristopheer96/.rbenv/versions/2.3.1/lib/ruby/2.3.0/tsort.rb:226:in `tsort_each' from /Users/Cristopheer96/.rbenv/versions/2.3.1/lib/ruby/2.3.0/tsort.rb:205:in `tsort_each' from /Users/Cristopheer96/code/Cristopheer96/Guudjob/backend-ror/vendor/cache/ruby/2.3.0/gems/railties-4.2.2/lib/rails/initializable.rb:54:in `run_initializers' from /Users/Cristopheer96/code/Cristopheer96/Guudjob/backend-ror/vendor/cache/ruby/2.3.0/gems/railties-4.2.2/lib/rails/application.rb:352:in `initialize!' from /Users/Cristopheer96/code/Cristopheer96/Guudjob/backend-ror/config/environment.rb:5:in `<top (required)>' from /Users/Cristopheer96/code/Cristopheer96/Guudjob/backend-ror/vendor/cache/ruby/2.3.0/gems/activesupport-4.2.2/lib/active_support/dependencies.rb:274:in `require' from /Users/Cristopheer96/code/Cristopheer96/Guudjob/backend-ror/vendor/cache/ruby/2.3.0/gems/activesupport-4.2.2/lib/active_support/dependencies.rb:274:in `block in require' from /Users/Cristopheer96/code/Cristopheer96/Guudjob/backend-ror/vendor/cache/ruby/2.3.0/gems/activesupport-4.2.2/lib/active_support/dependencies.rb:240:in `load_dependency' from /Users/Cristopheer96/code/Cristopheer96/Guudjob/backend-ror/vendor/cache/ruby/2.3.0/gems/activesupport-4.2.2/lib/active_support/dependencies.rb:274:in `require' from /Users/Cristopheer96/code/Cristopheer96/Guudjob/backend-ror/config.ru:3:in `block in <main>' from /Users/Cristopheer96/code/Cristopheer96/Guudjob/backend-ror/vendor/cache/ruby/2.3.0/gems/rack-1.6.13/lib/rack/builder.rb:55:in `instance_eval' from /Users/Cristopheer96/code/Cristopheer96/Guudjob/backend-ror/vendor/cache/ruby/2.3.0/gems/rack-1.6.13/lib/rack/builder.rb:55:in `initialize' from /Users/Cristopheer96/code/Cristopheer96/Guudjob/backend-ror/config.ru:in `new' from /Users/Cristopheer96/code/Cristopheer96/Guudjob/backend-ror/config.ru:in `<main>' from /Users/Cristopheer96/code/Cristopheer96/Guudjob/backend-ror/vendor/cache/ruby/2.3.0/gems/rack-1.6.13/lib/rack/builder.rb:49:in `eval' from /Users/Cristopheer96/code/Cristopheer96/Guudjob/backend-ror/vendor/cache/ruby/2.3.0/gems/rack-1.6.13/lib/rack/builder.rb:49:in `new_from_string' from /Users/Cristopheer96/code/Cristopheer96/Guudjob/backend-ror/vendor/cache/ruby/2.3.0/gems/rack-1.6.13/lib/rack/builder.rb:40:in `parse_file' from /Users/Cristopheer96/code/Cristopheer96/Guudjob/backend-ror/vendor/cache/ruby/2.3.0/gems/rack-1.6.13/lib/rack/server.rb:300:in `build_app_and_options_from_config' from /Users/Cristopheer96/code/Cristopheer96/Guudjob/backend-ror/vendor/cache/ruby/2.3.0/gems/rack-1.6.13/lib/rack/server.rb:209:in `app' from /Users/Cristopheer96/code/Cristopheer96/Guudjob/backend-ror/vendor/cache/ruby/2.3.0/gems/railties-4.2.2/lib/rails/commands/server.rb:61:in `app' from /Users/Cristopheer96/code/Cristopheer96/Guudjob/backend-ror/vendor/cache/ruby/2.3.0/gems/rack-1.6.13/lib/rack/server.rb:337:in `wrapped_app' from /Users/Cristopheer96/code/Cristopheer96/Guudjob/backend-ror/vendor/cache/ruby/2.3.0/gems/railties-4.2.2/lib/rails/commands/server.rb:139:in `log_to_stdout' from /Users/Cristopheer96/code/Cristopheer96/Guudjob/backend-ror/vendor/cache/ruby/2.3.0/gems/railties-4.2.2/lib/rails/commands/server.rb:78:in `start' from /Users/Cristopheer96/code/Cristopheer96/Guudjob/backend-ror/vendor/cache/ruby/2.3.0/gems/railties-4.2.2/lib/rails/commands/commands_tasks.rb:80:in `block in server' from /Users/Cristopheer96/code/Cristopheer96/Guudjob/backend-ror/vendor/cache/ruby/2.3.0/gems/railties-4.2.2/lib/rails/commands/commands_tasks.rb:75:in `tap' from /Users/Cristopheer96/code/Cristopheer96/Guudjob/backend-ror/vendor/cache/ruby/2.3.0/gems/railties-4.2.2/lib/rails/commands/commands_tasks.rb:75:in `server' from /Users/Cristopheer96/code/Cristopheer96/Guudjob/backend-ror/vendor/cache/ruby/2.3.0/gems/railties-4.2.2/lib/rails/commands/commands_tasks.rb:39:in `run_command!' from /Users/Cristopheer96/code/Cristopheer96/Guudjob/backend-ror/vendor/cache/ruby/2.3.0/gems/railties-4.2.2/lib/rails/commands.rb:17:in `<top (required)>' from /Users/Cristopheer96/code/Cristopheer96/Guudjob/backend-ror/bin/rails:9:in `require' from /Users/Cristopheer96/code/Cristopheer96/Guudjob/backend-ror/bin/rails:9:in `<top (required)>' from /Users/Cristopheer96/code/Cristopheer96/Guudjob/backend-ror/vendor/cache/ruby/2.3.0/gems/spring-1.5.0/lib/spring/client/rails.rb:28:in `load' from /Users/Cristopheer96/code/Cristopheer96/Guudjob/backend-ror/vendor/cache/ruby/2.3.0/gems/spring-1.5.0/lib/spring/client/rails.rb:28:in `call' from /Users/Cristopheer96/code/Cristopheer96/Guudjob/backend-ror/vendor/cache/ruby/2.3.0/gems/spring-1.5.0/lib/spring/client/command.rb:7:in `call' from /Users/Cristopheer96/code/Cristopheer96/Guudjob/backend-ror/vendor/cache/ruby/2.3.0/gems/spring-1.5.0/lib/spring/client.rb:28:in `run' from /Users/Cristopheer96/code/Cristopheer96/Guudjob/backend-ror/vendor/cache/ruby/2.3.0/gems/spring-1.5.0/bin/spring:49:in `<top (required)>' from /Users/Cristopheer96/code/Cristopheer96/Guudjob/backend-ror/vendor/cache/ruby/2.3.0/gems/spring-1.5.0/lib/spring/binstub.rb:11:in `load' from /Users/Cristopheer96/code/Cristopheer96/Guudjob/backend-ror/vendor/cache/ruby/2.3.0/gems/spring-1.5.0/lib/spring/binstub.rb:11:in `<top (required)>' from /Users/Cristopheer96/.rbenv/versions/2.3.1/lib/ruby/2.3.0/rubygems/core_ext/kernel_require.rb:55:in `require' from /Users/Cristopheer96/.rbenv/versions/2.3.1/lib/ruby/2.3.0/rubygems/core_ext/kernel_require.rb:55:in `require' from /Users/Cristopheer96/code/Cristopheer96/Guudjob/backend-ror/bin/spring:13:in `<top (required)>' from ./bin/rails:3:in `load' from ./bin/rails:3:in `<main>' ➜ backend-ror git:(dev) ✗
-
Devise Registration controller, every parameter seems to be removed
trying to override Devise Registration controller, following a couple examples online, but for some reason every parameter passed in seems to be removed. this is the controller.
class RegistrationsController < Devise::RegistrationsController skip_before_action :verify_authenticity_token, :only => :create def create p sign_up_params build_resource(sign_up_params) resource.save sign_up(resource_name, resource) if resource.persisted? render json: resource end end
this is the request
curl --location --request POST 'localhost:3000/buyer_users' \ --data-raw '{ "buyer_users": { "email":"peter245@email.com", "password":"123123123", "site_id":"103eb514-8185-4820-8f16-3a9d082c5f60", "account_id": "f362189f-a843-4c19-927a-845ce2cb0ad0" } }'
we seems to be picking up params, but everything is removed
21:16:05 web.1 | Started POST "/buyer_users" for ::1 at 2022-05-06 21:16:05 -0700 21:16:05 web.1 | Processing by RegistrationsController#create as JSON 21:16:05 web.1 | Parameters: {"{\n \"buyer_users\": {\n \"email\":\"peter245@email.com\",\n \"password\":\"123123123\",\n \"site_id\":\"103eb514-8185-4820-8f16-3a9d082c5f60\",\n \"account_id\": \"f362189f-a843-4c19-927a-845ce2cb0ad0\"\n }\n}"=>"[FILTERED]"} 21:16:05 web.1 | {} 21:16:05 web.1 | Completed 200 OK in 7ms (Views: 0.1ms | ActiveRecord: 0.0ms | Allocations: 1155)
routes are set up like this
devise_for :buyer_users, defaults: { format: :json }, controllers: { registrations: 'registrations' }
EDIT: after debugging some more it seems that the entire parameter is taken in as 1 string.
-
Whats missing on my Ruby 'Inverse Of' relationship
I know this topic has been addressed, but I have been at this for 2 days and I'm just stuck. I know inverse of does not create a new query, so should I use another method?
Question: How to set up an 'inverse of' with a has_one, belongs_to situation & same class..
Explanation: A user 'has_one :spouse' and 'belongs_to :spouse_from'. They are inverse of each other. When a User signs up, they can invite their significant other. For Example
- user_a invites & creates user_b
- user_b.spouse_id is set to user_a.id
- In a separate method I want to be able to update like.. user_a.spouse_id = user_a.spouse.id
The only association that works at this point is user_b.spouse.
Class User has_one :spouse, class_name: 'User', foreign_key: :spouse_id, dependent: :nullify, inverse_of: :spouse_from belongs_to :spouse_from, class_name: 'User', foreign_key: :spouse_id, inverse_of: :spouse, optional: true
-
Node module css import paths work in development, but not in production
I am moving from Webpack to esbuild with jsbundling-rails & cssbundling-rails.
I have a folder which imports css libraries from vendors like so:
@import "drift-zoom/dist/drift-basic.min.css"; @import "dropzone/dist/min/dropzone.min.css"; @import "select2/dist/css/select2.css";
This works without issue in development, but in production I get an errors like:
ActionController::RoutingError (No route matches [GET] "/assets/select2/dist/css/select2.css"):
The problem is clearly that it is looking for theses file in assets, when instead it should be looking in the node_modules folder at the root directory.
I have
Rails.application.config.assets.paths << Rails.root.join('node_modules')
in config/initializers/assets.rbHow should these import paths be written to work in production too? Or am I missing something in my setup?
My package.json script for css is:
"build:css": "sass ./app/assets/stylesheets/application.sass.scss ./app/assets/builds/application.css --no-source-map --load-path=node_modules"
-
No route matches [GET] "/assets/application.js & No route matches [GET] "/assets/application.css
I am moving away from Webpack to Esbuild, using jsbundling-rails and cssbundling-rails.
Rails version is 6.1.5
Everything seems to be working fine, but in my logs I get:
ActionController::RoutingError (No route matches [GET] "/assets/application.js-71bd51ca6859614cd46b64034f1484dfa019cb295ac852a804b8c30fc2f9ba0b.map"): ActionController::RoutingError (No route matches [GET] "/assets/application.css-3b0754679fcb32c2b76c56e443ad8651a084344d65ce5995fe745125487fbda9.map"):
I can't work out what process is still looking for files at these locations.
-
speed up react with typescript project build in development mode
I have a React project using Typescript built using create react app. The start command
react-scripts start
takes around 50s on first time and around 3 seconds on any file change.How can I speed up the build time specially after each change in code?
Some things I already tried
- Used craco and introduced esbuild instead of babel
- Disabled eslint in dev mode But these did not gave me much improvement in speed.
In which direction I should be debugging this more?
-
Can I install Importmap or JS/CSS Bundling alongside Webpacker on Rails 6?
Looking to potentially install Importmap or JS/CSS Bundling alongside my existing Webpacker installation in my Rails 6 app. The idea is to test and migrate existing UI code over ahead of a Rails 7 upgrade. Has anybody has any success with this? I've done some basic installs and have run into errors with both, and don't want to spend a ton of time debugging something that's ultimately not going to work anyway. Thanks!