Skip to content

Not possible to defer parsing until all dependencies have been loaded #71

@drbenschmidt

Description

@drbenschmidt

I've run into an issue when using variables defined in one LESS file not existing later for other modules because the LESS is parsed for each dependency instead of aggregating each dependency and parsing them all at the end.

I'm using Backbone Marionette and have setup my project similarly to a typical MVC framework, however each of my view folders contain the Backbone Marionette View, Handlebars Template, and LESS file. When I create my Application View, I use require-less to include my default application LESS, which includes imports to bootstrap and some overrides, as well as newly defined variables.

Here is a quick visual for how it's structured:

- Views
  |-- ApplicationView
      |-- ApplicationView.js  <-- Requires HeaderVew
      |-- ApplicationTemplate.handlebars
      |-- ApplicationStyle.less  <-- Defines @image-base-path
  |-- HeaderView
      |-- HeaderView.js
      |-- HeaderTemplate.handlebars
      |-- HeaderStyle.less  <-- Requires @image-base-path

I've played around with the require-less/less.js file to introduce a new option for deferedParsing where if enabled it will store each required file in an array instead of parsing the import, then added a function that can be called once the loading is done. I wasn't able to normalize the CSS with this method, and this may not work for everyone. I also hadn't tried this approach in the builder yet.

Have you encountered this issue before, or do you have any ideas that could solve this issue without requiring a separate call to start the parsing?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions