Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Import Each Less File Only Once #212

Closed
michael-savory opened this issue Feb 26, 2011 · 18 comments
Closed

Import Each Less File Only Once #212

michael-savory opened this issue Feb 26, 2011 · 18 comments

Comments

@michael-savory
Copy link

This is somewhat a duplicate of issue #49, however I did not find any clarification on what the best strategy was. Also, I should mention that I'm doing all of my compiling on the server side using node.

Here is my problem.

home.less:

@import "config";

@import "reset";

@import "core";

@import "base";

How I would like this to work is that it's like I'm specifying all of my dependencies at the top of my less file, and it will get compiled down into one nice css file.

However, what you get instead is:

-- config.css

-- reset.css

-- config.css

-- core.css

-- config.css

-- core.css

-- base.css

-- home.css

Basically, everyone depends on "config", because that's where all my colors and functions are located, and it would be nice if that was only loaded only once. Notice, in my specific case "core" gets loaded twice as well.

Is there a workaround, a hack, an alternative, or a fork that deals with this scenario. I feel like it's valuable from the standpoint that you could have css files like the following:

home.css

index.css

posts.css

blogs.css

And these would more or less dynamically create themselves with only the necessary css components based upon the imports you specify.

Cheers.

@minipai
Copy link

minipai commented Apr 19, 2011

I would like this feature request too. SASS wont compile .scss files start with '_' such like _config.scss.

@lukeapage
Copy link
Member

@import-once is implemented

@jreading
Copy link
Contributor

Import once test fails, are we sure this is resolved?

@lukeapage
Copy link
Member

its implemented and there is another bug about it not working, now it is implemented. I'm just trying to sort the wood from the trees - don't worry I'd like to see this working too.

@jreading
Copy link
Contributor

Cool, thanks for stepping up!

One thing I wondered though is if a non "import-once" is ever needed. Seems like all imports should be "import-once" so wondering if the extra command is even necessary.

@barryvdh
Copy link

barryvdh commented Oct 1, 2012

So is this implemented or not? Can't find it in the docs..

@ljharb
Copy link
Contributor

ljharb commented Oct 4, 2012

I strongly agree - importing once should be the default, since I can't come up with a reason you'd ever want to import multiple.

@mjackson
Copy link

+1 There shouldn't be any need for @import-once. It should be the default behavior of @import. @cloudhead, what do you think?

@Soviut
Copy link

Soviut commented Oct 11, 2012

+1 for importing once being the default behaviour.

@lukeapage lukeapage reopened this Oct 18, 2012
@lukeapage
Copy link
Member

reopened to track

@jakefolio
Copy link

+1 for import-once being the default import behavior

@matthew-dean
Copy link
Member

+1

@import-once is not needed nor should be present, since @import should result in a single import.

@liorama
Copy link

liorama commented Oct 30, 2012

👍
Single imports rule!

@nitm
Copy link

nitm commented Oct 30, 2012

👍

2 similar comments
@nitzantomer
Copy link

👍

@poadi
Copy link

poadi commented Oct 30, 2012

👍

@lukeapage
Copy link
Member

ok, you all win!

I've changed this to high priority so its on my list of things to do when I get a chance.

unless anyone wants to make a pull request?

@ljharb
Copy link
Contributor

ljharb commented Oct 30, 2012

sorry for the multiple mentions, i edited my commit message a few times. @agatronic will pull request #1010 work?

lukeapage pushed a commit that referenced this issue Nov 27, 2012
- Add @import-multiple if for some insane reason you want multiple imports.
- Continue to support @import-once for backwards compatibility.
- Fixes #212.
lukeapage pushed a commit that referenced this issue Jan 2, 2013
- Add @import-multiple if for some insane reason you want multiple imports.
- Continue to support @import-once for backwards compatibility.
- Fixes #212.
lukeapage pushed a commit that referenced this issue Jan 5, 2013
- Add @import-multiple if for some insane reason you want multiple imports.
- Continue to support @import-once for backwards compatibility.
- Fixes #212.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.