Close Menu
    DevStackTipsDevStackTips
    • Home
    • News & Updates
      1. Tech & Work
      2. View All

      Low-Code vs No-Code Platforms for Node.js: What CTOs Must Know Before Investing

      September 12, 2025

      ServiceNow unveils Zurich AI platform

      September 12, 2025

      Integrating CSS Cascade Layers To An Existing Project

      September 11, 2025

      How React.js AI Code Generation Accelerates Digital Transformation Initiatives

      September 11, 2025

      GitHub Availability Report: August 2025

      September 11, 2025

      GitHub Copilot coding agent 101: Getting started with agentic workflows on GitHub

      September 11, 2025

      Compiling Multiple CSS Files into One

      September 11, 2025

      When Cells Collide: The Making of an Organic Particle Experiment with Rapier & Three.js

      September 11, 2025
    • Development
      1. Algorithms & Data Structures
      2. Artificial Intelligence
      3. Back-End Development
      4. Databases
      5. Front-End Development
      6. Libraries & Frameworks
      7. Machine Learning
      8. Security
      9. Software Engineering
      10. Tools & IDEs
      11. Web Design
      12. Web Development
      13. Web Security
      14. Programming Languages
        • PHP
        • JavaScript
      Featured

      PHP 8.5.0 Beta 3 available for testing

      September 12, 2025
      Recent

      PHP 8.5.0 Beta 3 available for testing

      September 12, 2025

      Stock Prediction using Python machine Learning (ML)

      September 12, 2025

      How to Successfully Upgrade Angular 16 to 17: Handling Legacy Angular Material Components

      September 12, 2025
    • Operating Systems
      1. Windows
      2. Linux
      3. macOS
      Featured

      Pironman 5 Max Review: Best Raspberry Pi Case Money can Buy

      September 12, 2025
      Recent

      Pironman 5 Max Review: Best Raspberry Pi Case Money can Buy

      September 12, 2025

      Distribution Release: Voyager Live 13

      September 11, 2025

      FOSS Weekly #25.37: Mint 22.2 Released, Official KDE Distro, Kazeta Linux for 90s Gaming, Ubuntu 25.10’s New Terminal and More Linux Stuff

      September 11, 2025
    • Learning Resources
      • Books
      • Cheatsheets
      • Tutorials & Guides
    Home»News & Updates»Compiling Multiple CSS Files into One

    Compiling Multiple CSS Files into One

    September 11, 2025

    Stu Robson is on a mission to “un-Sass” his CSS. I see articles like this pop up every year, and for good reason as CSS has grown so many new legs in recent years. So much so that much of the core features that may have prompted you to reach for Sass in the past are now baked directly into CSS. In fact, we have Jeff Bridgforth on tap with a related article next week.

    What I like about Stu’s stab at this is that it’s an ongoing journey rather than a wholesale switch. In fact, he’s out with a new post that pokes specifically at compiling multiple CSS files into a single file. Splitting and organizing styles into separate files is definitely the reason I continue to Sass-ify my work. I love being able to find exactly what I need in a specific file and updating it without having to dig through a monolith of style rules.

    But is that a real reason to keep using Sass? I’ve honestly never questioned it, perhaps due to a lizard brain that doesn’t care as long as something continues to work. Oh, I want partialized style files? Always done that with a Sass-y toolchain that hasn’t let me down yet. I know, not the most proactive path.

    Stu outlines two ways to compile multiple CSS files when you aren’t relying on Sass for it:

    Using PostCSS

    Ah, that’s right, we can use PostCSS both with and without Sass. It’s easy to forget that PostCSS and Sass are compatible, but not dependent on one another.

    postcss main.css -o output.css

    Stu explains why this could be a nice way to toe-dip into un-Sass’ing your work:

    PostCSS can seamlessly integrate with popular build tools like webpack, Gulp, and Rollup, allowing you to incorporate CSS compilation into your existing development workflow without potential, additional configuration headaches.

    Custom Script for Compilation

    The ultimate thing would be eliminating the need for any dependencies. Stu has a custom Node.js script for that:

    const fs = require('fs');
    const path = require('path');
    // Function to read and compile CSS
    function compileCSS(inputFile, outputFile) {
        const cssContent = fs.readFileSync(inputFile, 'utf-8');
        const imports = cssContent.match(/@imports+['"]([^'"]+)['"]/g) || [];
        let compiledCSS = '';
        // Read and append each imported CSS file
        imports.forEach(importStatement => {
            const filePath = importStatement.match(/['"]([^'"]+)['"]/)[1];
            const fullPath = path.resolve(path.dirname(inputFile), filePath);
            compiledCSS += fs.readFileSync(fullPath, 'utf-8') + 'n';
        });
        // Write the compiled CSS to the output file
        fs.writeFileSync(outputFile, compiledCSS.trim());
        console.log(`Compiled CSS written to ${outputFile}`);
    }
    // Usage
    const inputCSSFile = 'index.css'; // Your main CSS file
    const outputCSSFile = 'output.css'; // Output file
    compileCSS(inputCSSFile, outputCSSFile);

    Not 100% free of dependencies, but geez, what a nice way to reduce the overhead and still combine files:

    node compile-css.js

    This approach is designed for a flat file directory. If you’re like me and prefer nested subfolders:

    With the flat file structure and single-level import strategy I employ, nested imports (you can do with postcss-import aren’t necessary for my project setup, simplifying the compilation process while maintaining clean organisation.

    Very cool, thanks Stu! And check out the full post because there’s a lot of helpful context behind this, particularly with the custom script.


    Compiling Multiple CSS Files into One originally published on CSS-Tricks, which is part of the DigitalOcean family. You should get the newsletter.

    Source: Read More 

    Facebook Twitter Reddit Email Copy Link
    Previous ArticleWhen Cells Collide: The Making of an Organic Particle Experiment with Rapier & Three.js
    Next Article GitHub Copilot coding agent 101: Getting started with agentic workflows on GitHub

    Related Posts

    News & Updates

    GitHub Availability Report: August 2025

    September 11, 2025
    News & Updates

    GitHub Copilot coding agent 101: Getting started with agentic workflows on GitHub

    September 11, 2025
    Leave A Reply Cancel Reply

    For security, use of Google's reCAPTCHA service is required which is subject to the Google Privacy Policy and Terms of Use.

    Continue Reading

    Sam Altman Talks GPT-5, AGI, and AI Privacy in OpenAI’s First Podcast Episode – Know More

    Operating Systems

    CVE-2025-30324 – Adobe Photoshop Integer Underflow Arbitrary Code Execution Vulnerability

    Common Vulnerabilities and Exposures (CVEs)

    CVE-2025-37783 – Linux Kernel drm/msm Error Pointer Dereference Vulnerability

    Common Vulnerabilities and Exposures (CVEs)

    CVE-2025-6776 – Xiaoyunjie OpenVPN-CMS-Flask Remote Path Traversal

    Common Vulnerabilities and Exposures (CVEs)

    Highlights

    Evaluating potential cybersecurity threats of advanced AI

    April 2, 2025

    Post Content Source: Read More 

    Windows 11 tests “shared audio” to play music via multiple devices, new taskbar animations

    July 20, 2025

    Your Customers See More Than Reality: Is Your Mobile Strategy Keeping Up?

    July 1, 2025

    AI Consulting for QA: Drive Efficiency and Business Growth

    September 3, 2025
    © DevStackTips 2025. All rights reserved.
    • Contact
    • Privacy Policy

    Type above and press Enter to search. Press Esc to cancel.