Ruby on Rails: How to organize JS and CSS files correctly?

I would like to use the SlickGrid plugin in my Rails 3 application. I have several JS and CSS files that I have to include in my HTML page.

You can put all the necessary JS files in a directory public/javascriptsand all CSS files in a directory public/stylesheets. However, I do not like this solution because it breaks down the structure of the plugin package files.

I would like to put all the plugin files in one place (I thought about vendor/plugins, is this the best place?) And include the necessary files there. Is it possible?

What is the correct way to include JS and CSS files when integrating a plugin?

+3
source share
2

, Jammit , . , , gzipping , javascript . ( ) , .

+2

@rubiii , sprockets gem 2.10.0 bower, js/css. , bower install. Bower nodejs npm install -g bower, .bowerrc :

{
   "directory": "vendor/assets/components"
}

bower.json bower install

{
  "name": "appName",
  "version": "0.0.0",
  "dependencies": {
    "bootstrap": "~3.0.0",
  }
}

, , application.js/application.css. .

*= require bootstrap
0

Source: https://habr.com/ru/post/1793215/


All Articles