Tips for avoiding the combination of CSS into one file using gulp-sass in Gulp

Is there a way to specify gulp-sass to process SASS files while preserving the structure of the source folder? We do not want them to be minified or combined into one main file. For instance, if we have:

src/
  components/
    _header.scss
    _sidebar.scss
    _card.scss

Is it possible to process them into:

dist/
  components/
    header.css
    sidebar.css
    card.css

Gulpfile

gulp.task('styles:dist', () => {
  return gulp
    .src('./src/styles/**/*.+(scss|sass|css)', { base: './' })
    .pipe(
      sass({
        outputStyle: 'expanded',
      }).on('error', sass.logError)
    )
    .pipe(gulp.dest('./dist'));
});

Thank you in advance!

Answer №1

To begin, make sure to first integrate the cleanCSS gulp plugin into your project. Once that is done, execute your task to convert SCSS, SASS, or LESS files into CSS. Follow this by using the CSS task to merge and minify all CSS files into one single file.

var cleanCSS = require('gulp-clean-css');

gulp.task('css', () => {
return gulp.src('./src/styles/**/*.css')
  .pipe(cleanCSS({
      compatibility: 'ie8',
      level: {
          1: {
              specialComments: 0,
          },
      },
  }))
  .pipe('./dist'))
});

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Achieving one-directional movement in Line by utilizing scale manipulation in CSS

hr:hover { transform:scaleX(50.0); } CSS when Hover hr { position: absolute; transition: transform 1.5s ease-out; width: 3%; height: 3px; background-color: white; margin-left: 20%; margin-top: 10%; } CSS of Line Is there a way to scale t ...

What steps should I follow to make a section stay in place on swipepages?

Looking for help to create a sticky section similar to the one on (mobile version). I want to replicate this section with 2 buttons on swipepages.com but I'm not sure about the custom CSS and HTML needed to achieve this. Any assistance would be appre ...

What steps should I take to resolve the textarea border bottom CSS effect?

My simple border bottom animation is working fine with a basic input element, but it's not functioning properly when used with a textarea. (If using JavaScript is necessary for a solution, please provide guidance) How can I adjust the height of a te ...

How can text be concealed within an input field?

My degrees converter code is functioning well, but I have an issue. When I input a number for one temperature type, the conversion for the other two types is displayed correctly. However, if I then enter a number for another temperature type, the previous ...

Is it possible to control my CSS using ModX Resources?

I have recently been experimenting with the ModX Revolution manager and had a question about converting my CSS into ModX Resources instead of files. I am interested in utilizing Templates and their variables as well. Do you know if this is possible? Also, ...

Automatically loading a div using jQuery after a delay of 5 seconds

I am working on a feature for my homepage that involves 4 div bars. Right now, I have them set to load upon click, but I would like to adjust it so that the first div loads when the page initially loads, and then each subsequent div loads after a certain t ...

What is the best way to evenly space 3 divisions in a row so that the last element is centered on the page?

Is there a way to align three divs horizontally, evenly spaced, in a manner that positions the rightmost element at the center of the page? ...

The background image does not appear to be displaying correctly on GitHub pages

I've encountered an issue where my svgs are not displaying as background-image or background on GitHub pages, even though they work fine locally. I utilized sass as a preprocessor for css, in case that detail is helpful. If anyone has insights on how ...

Tips for creating smoother transition animations with ng-show/ng-hide in AngularJS

Our development team at ServiceNow is currently working on a project that involves incorporating multiple widgets into different tabs on a page. To show and hide these tabs, we are utilizing the ng-show/ng-hide method along with applying some basic transit ...

What is the correct way to implement ::v-deep(<inner-selector>) in a Vue component?

I am attempting to assign an existing style class to a child element that will be loaded using the v-html directive. Since /deep/ and >>> are no longer supported, I have tried using ::v-deep in Vue. <template> <div v-else v-html="chi ...

Tips for resizing a browser window using an HTML element

I decided to add a unique feature to my website - a handle in the bottom right corner that users can grab and drag to the left to see how the design adapts to different browser window sizes (Responsive Design). To implement this, I included the following ...

Tips for enhancing transition animations in VueJS

I am looking to create a seamless transition between two states shown in the images below: https://i.sstatic.net/SxaZK.png The initial state: https://i.sstatic.net/OkSeq.png You can view my current progress on Codepen: Codepen Link <transition name= ...

Problem encountered with the submission feature in Zend Framework

I am encountering an issue with the submit button icon not displaying. In my .php file, I have the following code: $submit = new Zend_Form_Element_Submit('submit'); $submit ->setLabel(Zend_Registry::get('Zend_Translate')->tra ...

Enhance the appearance of your Table footer with a personalized touch

I have two different Text components that I am working with. You can view some examples of these components here. Here is the scenario: Text1 is located within a form (labeled as text) Text2 is situated in the footer area of a table In each text, I hav ...

What other options are there to use instead of word-break: break-all?

Here is my current setup: <div style="word-break: break-all; width 50px;">... long text ...</div> It functions just as I desire. However, the editor is indicating: CSS validation: 'word-break' is not a valid CSS property name. ...

Dividing a Price using Django Template Language

I am attempting to achieve a specific functionality in a Django Template Editor where I need to display a quarter of a price. The value quote.total is calculated by the system, such as 1235.00, and I want to manipulate this value to show 308.75 (which is ...

Angular 2: Enhancing Tables

I am looking to create a custom table using Angular 2. Here is the desired layout of the table: https://i.sstatic.net/6Mrtf.png I have a Component that provides me with data export class ResultsComponent implements OnInit { public items: any; ngO ...

Certain CSS classes are functioning properly, while others are not operating as expected

I am in the process of developing an ASP.Net page and utilizing Bootstrap, which has been functioning properly. Additionally, I have integrated a custom stylesheet to refine the appearance of the page. However, within the last couple of days, any new class ...

Looking for ways to include CSS links in Sublime Text 2 program?

Currently, I am diving into the world of Sublime Text 2 and I must say, I am quite impressed with its capabilities. However, there are a few features that I miss from my previous editor (Microsoft Expression Web). One particular functionality I found extr ...

Seeking a light-weight, text-rich editor specifically designed for use on our enterprise website. This editor should be even lighter than TinyMCE

I am in search of a lightweight text editor for an enterprise website, lighter than tinymce with basic buttons for the comment form. It is imperative that the editor also functions properly in IE6. So far, I have tried cleditor 15KB, but it has an issue in ...