P
P
Pavel Grudinkin2017-02-15 03:35:51
Ruby on Rails
Pavel Grudinkin, 2017-02-15 03:35:51

How to properly split assets?

There is a project for which I made a mobile version. The mobile version does not need a full set of external styles and js libraries, but there are a couple of common ones. Mobile assets in the resulting files of the general version are also not needed. I tried to exclude from the general version with the stub option, but then shared libraries are excluded from it. How do you usually act in such situations?

/assets
  /javascripts
    application.js(main version)
    main_version_js_files
    /mobile_version_folder
      application.js
      some_js_files
  /stylesheets
    application.css
    main_version_css_files
    /mobile_version_folder
      application.css
      some_css_files

Shared external libraries are in vendors/assets

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Alexander Leonchik, 2017-02-16
@Hunt666

I'll show you with an example of styles

assets/
  stylesheets/
    mobile/
    shared/
    application.scss
    mobile.scss
    shared.scss

shared.scss - this file is loaded everywhere and contains everything shared, for example
@import 'bootstrap';
@import 'jquery-ui';
@import 'shared/*';

application.scss - the main project file, which is loaded as default when viewed through a browser, for example. Here we load a common shared + something of our own, for example
@import 'shared';

@import .......

mobile.scss - mobile version, contains styles that are loaded only for mobile phones + of course shared
@import 'shared';
@import 'mobile/*';

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question