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

CSS should not auto-add to the HTML #1

Closed
chrisjhoughton opened this issue Dec 24, 2013 · 9 comments
Closed

CSS should not auto-add to the HTML #1

chrisjhoughton opened this issue Dec 24, 2013 · 9 comments

Comments

@chrisjhoughton
Copy link

Hi there,

Thanks for the module - really helped me out. However what I was looking to do with this was append the required CSS into a child iframe, which was impossible without modifying the module.

I've forked the module and place it here: https://github.com/chrisjhoughton/node-lessify/blob/master/index.js. Thoughts? (Note - tests are temporarily removed as they weren't applicable as they were.)

Chris

@wilson428
Copy link
Owner

Interesting, thanks for the note! So you return the compiled, minified CSS as a string, correct? And then manually add that string to the new element you create in the iFrame?

I'm absolutely amenable to adding an option of some sort that doesn't automatically append CSS -- makes fine sense. I'd like to keep the default behavior as simple as possible, but I think we could do that like so:

// default behavior
require("./styles.less");

// don't append, just return as a string
var compiled - require("./styles.less").text();

@chrisjhoughton
Copy link
Author

That's correct yes. I'm doing the same thing with HTML and it seemed logical to follow the same methodology for CSS.

.text() looks great, although I'm assuming you'd have to add another method (.load() for example to to what you're already doing as standard, right?

@wilson428
Copy link
Owner

Oh right, I was thinking about a traditional node module, not a transformation. I'm not actually certain how best to pass an argument to a transformation. Any ideas?

@wilson428
Copy link
Owner

Some brief discussion of passing variables to transformations here. Will investigate.

@CMCDragonkai
Copy link

@wilson428 Is there any progress on this idea?

@wilson428
Copy link
Owner

Thanks for the nudge. There's some discussion of how configurations could be sent to transformations in this browserify issue, and @substack has suggested using environment variables. I'm inclined to use the latter since it's easier. Thoughts? Won't take long to implement I don't think.

@CMCDragonkai
Copy link

I'm not sure I like the idea of environment variables since it's very global. How would it work, might it conflict with other project's variables.

@wilson428
Copy link
Owner

I added a textMode option passed through package.json for this use case -- see README. How's that work?

@wilson428
Copy link
Owner

Closing this for now. Feel free to reopen if above solution is problematic.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants