GithubHelp home page GithubHelp logo

Comments (12)

jhilden avatar jhilden commented on May 22, 2024

The main difference between Sprocket's require and Sass's @import is that the requires only concatinate the already compiled Sass, so there is no chance to reuse Sass variables, mixins, etc. from on file in the other. More information here: http://sass-lang.com/docs/yardoc/file.SASS_REFERENCE.html#import What exactly is missing in the examples in the README to make them better understandable? I would really appreciate feedback on how to improve them.

Does application.css.sass replace application.css entirely?

Yes. Not sure what would happen if you have both, but you definitely shouldn't. You need to give your application.css a .sass (or .scss) file extension in order us Sass functionality in there.

Does that help you?

from jquery-ui-sass-rails.

jondkinney avatar jondkinney commented on May 22, 2024

So my question is how to covert the standard manifest requires into @imports? Do you just replace every require with @import and call it good? Do you have to be more specific with the pathing? Does it have the ability to require_tree like the manifest does? Or do you have to @import every single file you want to include?

Here's my current application.js. Perhaps if you show me how it would look with this gem that'll help me get on the right page. Thanks.

// This is a manifest file that'll be compiled into including all the files listed below.
// Add new JavaScript/Coffee code in separate files in this directory and they'll automatically
// be included in the compiled file accessible from http://example.com/assets/application.js
// It's not advisable to add code directly here, but if you do, it'll appear at the bottom of the
// the compiled file.
//
// NOTE (2012-07-23) jonk => the files in this manifest list are organized by
// vendor/assets, lib/assets, app/assets
//
//= require jquery
//= require jquery_ujs
//= require jquery.ui.all
//= require jquery/jquery.cookie
//= require jquery/jquery.simplyCountable
//= require dataTables/jquery.dataTables
//= require redactor-rails
//= require data_tables
//= require utility
//= require bubbletip
//= require highcharts
//= require highcharts_fix
//= require html5
//= require modals
//= require_directory ./admin
//= require_directory ./campaigns
//= require_directory ./investor
//= require_directory ./charts
//= require turbolinks
//= require_tree .

from jquery-ui-sass-rails.

jhilden avatar jhilden commented on May 22, 2024

Oh, I think we have a little misunderstanding here. One should use Sass's @import over require only for stylesheets, not for JavaScript. Sass actually doesn't have anything to do with JavaScript. I already fixed the README a tiny bit, but maybe you can give me some more recommendations on how to make it even clearer?

Does that resolve your question?

from jquery-ui-sass-rails.

jondkinney avatar jondkinney commented on May 22, 2024

Sorry, I didn't mean to talk about and paste my application.js file. I meant to do it with my application.css file. I was/am/will be tired today :)

So do all the requires in the application.css get replaced with @imports of those files then? Do you have to specify every single file manually, etc, etc. I still have all the same questions.

And here is my application.css. Can you suggest how this would be converted to use your gem?

/*
* This is a manifest file that'll automatically include all the stylesheets available in this directory
* and any sub-directories. You're free to add application-wide styles to this file and they'll appear at
* the top of the compiled file, but it's generally better to create a new file per style scope.
*= require_self
*= require jquery.ui.all
*= require reset
*= require redactor-rails
*= require main
*= require pagination
*= require bubbletip
*/

from jquery-ui-sass-rails.

jondkinney avatar jondkinney commented on May 22, 2024

Because see, based on your Readme, it would have me doing this...

/*
* This is a manifest file that'll automatically include all the stylesheets available in this directory
* and any sub-directories. You're free to add application-wide styles to this file and they'll appear at
* the top of the compiled file, but it's generally better to create a new file per style scope.
*= require_self
*= require reset
*= require redactor-rails
*= require main
*= require pagination
*= require bubbletip
*/

$bgColorContent: purple // set custom value for jQueryUI variable

@import jquery.ui.core
@import jquery.ui.theme // your custom variables will be used here
@import jquery.ui.datepicker

But I don't think those files in the requires above will be picked up by the asset pipeline if we're putting those in an application.css.sass file... will they? Do you see my confusion now? How do I get from normal asset pipeline with the requires to also including your @imports?

Thanks,
Jon

from jquery-ui-sass-rails.

jhilden avatar jhilden commented on May 22, 2024

Actually the code above should work.

There is nothing stopping you from mixing require and @import, I just think it's a good idea to be consistent and to only use @import in your stylesheets. The major difference is that require will give you compiled CSS, while @import lets you use all the Sass functionality inside a stylesheet.

Let's say you have defined some variable inside bubbletip.sass, you wouldn't be able to access that variable anywhere else.

from jquery-ui-sass-rails.

jhilden avatar jhilden commented on May 22, 2024

Closing this issue. Feel free to reopen, if there are still things that need to be resolved.

from jquery-ui-sass-rails.

Tuman829 avatar Tuman829 commented on May 22, 2024

@jhilden Lets say that one wanted to fully convert the format to scss( @import rather then require) how would that look for the ```css
*= require self
*= require_tree .

?

from jquery-ui-sass-rails.

jhilden avatar jhilden commented on May 22, 2024

I don't fully understand your concrete question, could you rephrase it for me please?

from jquery-ui-sass-rails.

Tuman829 avatar Tuman829 commented on May 22, 2024

Should require self be converted to the @import format, if so how would that look?

from jquery-ui-sass-rails.

jhilden avatar jhilden commented on May 22, 2024

require_self is not necessary when using @import

application.css.sass:

@import 'something'

.my-class-here
  // this will be compiled in the application.css output without any additional code
  color: black

Does that help?

from jquery-ui-sass-rails.

sushil10018 avatar sushil10018 commented on May 22, 2024

Here is a nice explanation of how it can be used better: http://www.mattboldt.com/organizing-css-and-sass-rails/

#application.css
/*
 *= require_self
 *= require main
*/

then in the file stylesheets/main.scss

#main.scss
@import "jquery-ui";
@import "font-awesome";
@import "bootstrap-sprockets";
@import "base/bootstrap_variables";
@import "bootstrap";
@import "bootstrap-switch.min";
@import "jquery.datetimepicker";

from jquery-ui-sass-rails.

Related Issues (10)

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.