How do you add a header comment to files compiled by gulp

Viewed 379

I have a ASP .NET Core 3.1 project that is using gulp to compile a number of SCSS files and JS files.

Is there a way to add a header comment to the compiled files? I just want to put something like \* This file was generated. Don't mess with it! */ at the top of the files. I've tried just putting a file named _0-header.scss in hopes that alphabetically it would come up first, but since the file only contains commenting, it seems to be ignored.

What is the best way to include a header comment on the files that gulp generates?

My gulpfile.js has this code to compile the scss files:

// Define paths
const paths = {
    dist: {
        base: 'dist',
        img: 'dist/assets/img',
        libs: 'dist/assets/vendor'
    },
    base: {
        base: './wwwroot',
        node: 'node_modules'
    },
    src: {
        base: './wwwroot',
        css: './wwwroot/css',
        html: '**/*.html',
        img: './wwwroot/img/**/*.+(png|jpg|gif|svg)',
        js: './wwwroot/js/**/*.js',
        scss: './wwwroot/scss/**/*.scss'
    }
};

// Compile SCSS
const scssTask = function () {

    return src(paths.src.scss)
        .pipe(wait(500))
        .pipe(sass().on('error', sass.logError))
        .pipe(postcss([require('postcss-flexbugs-fixes')]))
        .pipe(autoprefixer({
            browsers: ['> 1%']
        }))
        .pipe(csscomb())
        .pipe(dest(paths.src.css))
        .pipe(browserSync.reload({
            stream: true
        }))
        .on('end', function () { log('Processed ' + paths.src.scss + ' to ' + paths.src.css + '.'); });
};

0 Answers
Related