Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8681555
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T21:32:29+00:00 2026-06-12T21:32:29+00:00

in a node.js environment, instead of stylus generating the .css each time, would like

  • 0

in a node.js environment, instead of stylus generating the .css each time, would like to write the .css file to a directory to be served by nginx.

seems that versioning part of name, eg, client-<unixTime>.css, then nginx will be happy and page caching will work correctly.

are there any existent tools available for helping with this?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-12T21:32:30+00:00Added an answer on June 12, 2026 at 9:32 pm

    did not realize that stylus was also an executable that can be run one-time or as a demon. in either case will convert the .styl files to .css, putting them in the directory of your choice.

    in node.js, to get the executable

    sudo npm install stylus -g
    

    for me, using stylus this way is much preferred because of the way inflexibility of the stylus middleware. rather than address that, using executable. this also keeps the development and production node server more closely aligned, but does not solve the versioning issue.


    here is my function that compiles one file (synchronous):

    var stylus = require('stylus'),
        nib = require('nib');
    
    // compile stylus
    exports.css = function( fn, out ) {
      var buf = fs.readFileSync( fn, 'utf8' );
      var oldCode = ( fs.existsSync( out ) ) ? fs.readFileSync( out, 'utf8' ) : 'none';
      stylus( buf )
        .set( 'filename', fn )
        .use( nib() )
        .render( function(err,newCode) {
          if( err ) throw( 'stylus err: '+err );
          if( oldCode != newCode ) {
            console.log( 'stylus: creating '+out );
            fs.writeFileSync( out, newCode, 'utf8' );
          }
        });
    };
    

    (after compiling I gzip using non-current gz files using compress-buffer (sync)

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Being totally new into node.js environment and philosophy i would like answers to few
I have a node in cloud environment which is used now as nginx and
I would like to compile in two environment variables (BUILD_NUMBER and NODE_NAME) that our
I would like to have node modules installed only when you are setting up
I've recently upgraded my environment to Node v0.6.3 and some file upload functionality that
How can I set an environment variable in node.js? I would prefer not to
Today i saw this code, that was running in node.js environment. (>node.exe test.js) var
Can node.js be setup to recognize a proxy (like Fiddler for example) and route
Today I ran my Node.js application in production mode for the first time and
I'd like to use the distribution Node.js packages (or the chris-lea ppa for more

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.