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

Upgrade from Gulp 4.0.2 to 5.0.0 with Node V20-LTS is missing bundled js files #2807

Open
Svenmarim opened this issue Jun 3, 2024 · 3 comments

Comments

@Svenmarim
Copy link

What were you expecting to happen?

After running Gulp on my project, to have 22 files within the wwwroot/dist/js/bundles folder.

What actually happened?

I only have 19 files.

Please give us a sample of your gulpfile

const {
    src,
    dest,
    series,
    parallel
} = require("gulp");
const gulpif = require("gulp-if");
const babel = require("gulp-babel");
const sourcemaps = require("gulp-sourcemaps");
const concat = require("gulp-concat");
const del = require("del");
const merge = require("merge-stream");
var sass = require("gulp-dart-sass");
const cleanCSS = require('gulp-clean-css');
const babelConfig = require("./babelrc.json");
var flatten = require('gulp-flatten');

const config = require("./bundle.config");

var launch = require('./Properties/launchSettings.json');

const environment = launch.profiles.Backoffice.environmentVariables.ASPNETCORE_ENVIRONMENT || 'Production';

function bundleJs() {
    bundles = config.scripts.bundles
        .filter(item => item.bundleName && item.inputFiles.length > 0)
        .map(item => src(item.inputFiles, { base: "." })
            .pipe(gulpif(environment === 'Development', sourcemaps.init()))
            .pipe(babel(babelConfig))
            .pipe(concat(`bundles/${item.bundleName}`))
            .pipe(gulpif(environment === 'Development', sourcemaps.write(".")))
        .pipe(gulpif(item.flatten, flatten(item.flatten)))
        .pipe(dest(config.scripts.dist)));

    return merge([bundles]);
}

function bundleCss() {
    bundles = config.css.bundles
        .filter(item => item.bundleName && item.inputFiles.length > 0)
        .map(item => src(item.inputFiles, { base: "." })
            .pipe(gulpif(environment === 'Development', sourcemaps.init()))
            .pipe(cleanCSS({
                compatibility: 'ie9',
                level: {
                    1: {
                        specialComments: 0
                    }
                }
            }))
            .pipe(concat(`bundles/${item.bundleName}`))
            .pipe(gulpif(environment === 'Development', sourcemaps.write(".")))
        .pipe(gulpif(item.flatten, flatten(item.flatten)))
        .pipe(dest(config.css.dist)));

    return merge([bundles]);
}

function bundleScss() {
    css = src(config.scss.src)
        .pipe(sourcemaps.init())
        .pipe(sass()).on("error", sass.logError)
        .pipe(sourcemaps.write("."))
        .pipe(dest(config.scss.dest));

    return css;
}

function copyAssets() {
    bundles = config.assets.bundles
        .filter(item => item.inputFiles.length > 0)
        .map(item => src(item.inputFiles, { base: "." })
            .pipe(gulpif(environment === 'Development', sourcemaps.write(".")))
            .pipe(flatten({ includeParents: -1 } ))
            .pipe(dest(config.css.dist)));
          

    return merge([bundles]);
}

function copyVendors() {
    bundles = config.vendors.bundles
        .filter(item => item.inputFiles.length > 0)
        .map(item => src(item.inputFiles, { base: '.' })
            .pipe(flatten(item.flatten))
            .pipe(dest(`${config.vendors.dist}`)));

    return merge([bundles]);
}

function clean() {
    return del(["./wwwroot/dist/**"]);
};

/* Exposed tasks */

exports.clean = clean;
exports.bundleJs = bundleJs;
exports.bundleCss = bundleCss;
exports.bundleScss = bundleScss;
exports.copyAssets = copyAssets;
exports.copyVendors = copyVendors;

exports.default = series(
    exports.clean,
    exports.bundleScss,
    parallel(exports.bundleJs, exports.bundleCss, exports.copyAssets, exports.copyVendors));

Terminal output / screenshots

C:\Repos\Client-Backoffice\Backoffice> cmd.exe /c gulp -b "C:\Repos\Client-Backoffice\Backoffice" --color --gulpfile "C:/Repos/Client-Backoffice/Backoffice/Gulpfile.js" default
[09:51:05] Using gulpfile C:\Repos\Client-Backoffice\Backoffice\Gulpfile.js
09:51:05] Starting '09:51:05] Starting '[default'...
[clean'...
clean' after [09:51:05] Finished '61 ms
09:51:05] Starting '[bundleScss'...
bundleScss' after [09:51:08] Finished '3.05 s
09:51:08] Starting '09:51:08] Starting '09:51:08] Starting '09:51:08] Starting '[bundleJs'...
[bundleCss'...
[copyAssets'...
[copyVendors'...
WARNING (@babel/preset-env): The `corejs` option only has an effect when the `useBuiltIns` option is not `false`
[09:51:13] Finished 'copyVendors' after 4.46 s
09:51:13] Finished '4.55 s
[bundleCss' after bundleJs' after [09:51:13] Finished '4.65 s
09:51:13] Finished '4.81 s
[copyAssets' after default' after [09:51:13] Finished '7.92 s
Process terminated with code 0.

Please provide the following information:

  • OS & version [e.g. MacOS Catalina 10.15.4]: Windows
  • node version (run node -v): 20.14.0
  • npm version (run npm -v): 10.7.0
  • gulp version (run gulp -v): 5.0.0

Additional information

Missing application.min.js, application.min.js.map and jquery.vlidation.bundle.min.js

@lik3as
Copy link

lik3as commented Jun 24, 2024

Something similar happened to me. I found out that the package that contained the files had updated its version in my package.lock, and the bundled files location too.

@emimoun2

This comment has been minimized.

@phated
Copy link
Member

phated commented Jun 24, 2024

@Svenmarim unfortunately the core team doesn't have the capacity to debug your entire gulpfile. If you can reduce this to a simple case, we'd be more able to help. Otherwise, I can transfer this to a GitHub Discussion for you to get some community support.

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

4 participants