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
Errors when using browserify with a Rails Engine #167
Comments
I also tried to use a simple knock-knock-jokes wihout success. =/ |
I will commit a example app with the error as soon as possible. |
I think another person was asking about this in the past (searching issues should turn it up). I'm not sure what the issue is but PRs are welcomed if you want to take the time to dive into it. I unfortunately do not know what would cause the issue. It might be worth looking at how the plugins mentioned here: https://github.com/rails/sprockets-rails Which would be coffee-rails and sass-rails work. That is, if they work inside an engine. |
I see, thanks =) I'd love to contribute if there is a real problem with I found the d7143df#diff-04c6e90faac2675aa89e2176d2eec7d8R151 and I followed the instructions. First of all I changed the example.rb: require "example/engine"
module Example
class << self
def config
yield self
end
end
end Then I changed the engine.rb: require 'sprockets/railtie'
require 'browserify-rails'
module Example
class Engine < ::Rails::Engine
isolate_namespace Example
config.browserify_rails.paths << lambda { |p| p.start_with?(Engine.root.join("app").to_s) }
end
end Now the error changed to I created a public example with this error: https://github.com/Lucasosf/example Can you help me please @cymen ? =) |
I finally found the problem. The gem gets the config from There is no need to add configs to the # lib/example/engine.rb
require 'sprockets/railtie'
require 'browserify-rails'
module Example
class Engine < ::Rails::Engine
isolate_namespace Example
end
end I just added the node_modules of the engine in the paths of the dummy app: # test/dummy/config/application.rb
config.browserify_rails.paths << Rails.root.join('../../node_modules') Now I can use npm packages in my isolated engine. Thanks =D Perhaps can I add some instructions of using |
@Lucasosf Ah! Interesting. Yes, by all means instructions are very welcomed. You can fork and update the README and do a PR if that works for you. Sorry, I have been away for a bit and missed this thread until now. |
I'm trying to use the browserify with a Rails engine.
I followed the Getting Started but I'm geting the error
Uncaught ReferenceError: require is not defined
when requiring the Vue npm package.Any tip?
Thanks =)
The text was updated successfully, but these errors were encountered: