Code Monkey home page Code Monkey logo

Comments (2)

jwhitley avatar jwhitley commented on August 10, 2024

Hi @skorth, currently this is by design. requirejs-rails takes over the JavaScript side of the Rails asset pipeline. Any asset path name that contains javascripts is handled by the gem's build process, not by the asset pipeline.

There are two workarounds that come to mind. First, you could just use the order! plugin to bring in the non-module code. For example, in application.js:

require( ['jquery', 'underscore', 'order!rails'], function ($, _) {
  // ...
}

This is the approach I use in one app to pull in non-AMD libraries such as d3.

The second workaround avoids require.js completely. Create a new asset path for your non-module JavaScripts, like so:

# rails.js should now live in app/assets/non-amd

config.asset.paths << Rails.root.join("app","assets","non-amd")
config.assets.precompile += %w( rails.js admin/admin.css )

Any directory name other than javascripts should work just fine. requirejs-rails won't see it, and the traditional Rails asset pipeline will.

from requirejs-rails.

skorth avatar skorth commented on August 10, 2024

Hey @jwhitley,

thanks alot! I use the second approach like you suggested (http://guides.rubyonrails.org/asset_pipeline.html#asset-organization) and it works great. Would be nice to see a small advice within the readme.

Thanks for this great Gem!

from requirejs-rails.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.