Best way to resolve dependency order in a Rails pipeline?

I have a RoR application that uses many separate .less files to create my styles. I have one .less file without a file (config.less) which has variables used by other files. I can manually scan each of these child files and add @import , but I have a lot of them, and this doesn't seem to be the best way. Is there a standard way to set a specific order if I use *= require_tree . ?

I tried to enable it over require_tree with

 ... *= require 'less/config' *= require_tree . 

but I still get the error message in the subsequent .less file complaining that it cannot find the value in config

 variable @base is undefined (in /Users/me/project/app/assets/stylesheets/less/mixins.less) 
+4
source share
1 answer

The standard way is not to use *= require_tree . and separately indicate import / necessity strings.

From the Rails Guide

Directives are processed from top to bottom, but the order in which require_tree files are included is not specified. You should not rely on any particular order among them. If you need to make sure that a particular JavaScript ends above another in a concatenated file, you must first provide the precondition file in the manifest. Please note: the require family of directives does not allow files to be included in a file twice.

+4
source

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


All Articles