Closed Dmitriy-Frostoff closed 7 months ago
Thanks for the report. I haven't debugged anything here, but I think the issue is that glob-stream always starts at the cwd
and your cwd
is being changed to the location of the gulpfile.
Can you try adding an explicit cwd to your src? Something like { cwd: "../.." }
as the second argument
If the above proves to solve the issue, we may need to resolve the "most common directory" of all globs to start the walkdir π€
Blaine, thanks for your help!!! π π π π
Your tip cured the situation! π π π π
I've followed your tip and done this steps:
src
relative to the project rootcwd: "../../"
as the optional (second) parametersrc
done it's work smoothly
my actual gulpfile.js
, placed in the configs/gulp/gulpfile.js
(as previously), now looks like this:gulpfile.js
configimport gulp from 'gulp';
const { src, dest, series } = gulp;
import include from 'gulp-file-include';
import replace from 'gulp-replace';
import rename from 'gulp-rename';
export function html() {
return src('projectName/src/pages/index_gulp_include.html', {
cwd: '../../',
})
.pipe(
include({
prefix: '@@',
indent: true,
}),
)
.pipe(replace(/="(\.\.\/){2,}/gi, '="../'))
.pipe(rename('index.html'))
.pipe(dest('../../projectName/src/pages/'));
}
$ npx gulp --gulpfile ./configs/gulp/gulpfile.js html
[11:30:15] Working directory changed to E:\Code learning\boilerplate-webpack-gulp-html-scss-js-components\configs\gulp
[11:30:15] Using gulpfile E:\Code learning\boilerplate-webpack-gulp-html-scss-js-components\configs\gulp\gulpfile.js
[11:30:15] Starting 'html'...
[11:30:15] Finished 'html' after 351 ms
P.S. and especially thanks for clearing up how to use optional cwd
, root
parameters. My knowledge of gulp has been strengthened now ππππ
As notice if you won't mind:
interesting thing but dest
is set to be relative to the current place of the gulpfile.js
and it works as expected (places bundled html
file to the projectName/src/pages/index.html
relative to the root). π€
I think it may be related to this bug: multilevel reinclusion don't work. With Gulp 4 I could properly chain an exclusion followed by a reinclusion, Gulp 5 doesn't reinclude the files that are an exception to an exclusion.
files: { src: [ './src/**/*.*', '!./src/vendor/**/*.*', './src/vendor/composer/**/*.*', './src/vendor/autoload.*', } };
I can confirm, that src
can no longer handle ../
at the beginning. This is the case when gulpfile is in a subdirectory like Build
and Resources
is outside of Build.
src('../Resources/Private/Sass/*')
no longer works
src('Resources/Private/Sass/*')
works
PS: dest
works sometimes with ../
at the beginning, but not in all cases.
What were you expecting to happen?
Expected
npx gulp --gulpfile ./configs/gulp/gulpfile.js html
to bundle html file viagulp-file-include
plugin and a few more ones (check thegulpfile.js
for details). P.S. via gulp@4.0.2 and gulp-cli@3.0.0 everything works fine.What actually happened?
Got the exception with the
globs argument
according to Gulp official docs.Please give us a sample of your gulpfile
Link to my bolerplate
gulpfile.js
is atconfigs/gulp/gulpfile.js
Terminal output / screenshots
Please provide the following information:
node -v
): v21.7.1npm -v
): 10.5.0gulp -v
): 5.0.0Steps to reproduce:
works fine;
Additional information
The problem occurs only when
gulpfile.js
placed not in a root of a project (in a root folder it works fine with the relevantsrc
paths). Via gulp@4.0.2 and gulp-cli@3.0.0 everything works fine. No globally installed packages were used. The boilerplate is set to use modules (type: module
inpackage.json
is set). Check the description for more.P.S. Thank you the
Gulpjs Team
for Hard work and Tools!!!gulpjs.com/docs
is Awesome resource for learning the tool! I really enjoyed the way you've done it - imho, one of the best ever! Great job done, Team!)))