New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Rails API + Webpacker? #1361
Comments
@foucist Flagging your app creation with an As such it wouldn't make sense to include webpacker, which only exists for that "missing" frontend You could use Rails as an api backend without removing the views. Adding a constraint like this in your routes file could very well make sense. namespace :api, constraints: { format: 'json' } do
resources :foo, only: :index
resources :bar, only: :create
end This would create the following routes:
You'd then build an SPA and serve it up at the root Otherwise, your best to get moving quickly is probably to use a client-centric boilerplate like create react app. This will likely include keeping track of two repos, a versioned API, and CORS requests |
thanks @danielpowell4 The other option is to use something like html webpack plugin, where you don't need views at all: made a quick example here: https://github.com/gauravtiwari/webpacker-api-frontend You can use a client side router to route appropriately. @foucist Does this answers your question? |
Is is possible to use with
rails new app --api --webpack
?Naturally it would be handled differently in production, but I thought it would be a quick way to host & manage an SPA side by side with a rails api in development mode.
Since there's no views, I can't use
<%= javascript_pack_tag '...' %>
The text was updated successfully, but these errors were encountered: