gulp add source maps from compiled scss file
Hi, i have this gulpfile.mjs in my project. I want to add source map from my SCSS file. How can i fix this? It does not generate map, i need it for better debugging
48 Replies
Btw, i should probably also mention this mjs file was generated by chatgpt. i dont understand much about that honestly ^^
you should investigate a bit about vite, instead of trying to use gulp-ish in the worst possible way
Well. Gulp seems pretty awesome to me. I don't know how to use vite. never used it and i know pretty much only the very basics of JavaScript. My main focus is CSS/SCSS. so it is a little difficult for me to move on to vite. but gulp seems to have all i need except from this source map thing that doesnt really want to work. But everything else is working perfectly 🙂
i will check that better in a bit
Thank you 🙂
https://stackoverflow.com/questions/38437860/gulp-sass-source-map <-- have you tried one of these?
Stack Overflow
gulp sass source map
I need help adding source map to SASS compiler in the same CSS output folder. Till now, I got to install gulp-sourcemaps module within gulpfile.js but couldn't know success to bind sourcemaps.write...
i tried to install this
gulp-sourcemaps
with node and i got some errors from this package... So i uninstalled itwhich errors?
i used this command
npm install gulp-sourcemaps --save-dev
and got this error
I tried npm audit fix
that did not work so i had to do npm audit fix --force
but i was afraid that it would mess something up with my project. So i uninstalled gulp-sourcemaps instead
So yeah, it was a warning, not an errorthat's a warning
Yeah
warnings arent errors
But something seems to be deprecated
so?
So i guess it wont work if its deprecated?
you're using a tool that's mostly unused
Oh hmm...
im surprised that gulp isn't deprecated at this point
Haha well. Everything except generating source maps seems to work just fine ^^
are you using gulp 5?
CLI version: 3.0.0
Local version: 5.0.0
So not sure if that means 3 or 5 ^^
me neither
vite is easier to use than gulp 😅
but you shouldn't worry about gulp making the source maps, it should be doing that as part of the process when compiling Sass,
Well. It doesnt do that unfortunately 😂 All it does is creating a compiled CSS file ^^
hmm, I haven't used gulp in so long, I need to refresh my memory
Yeah haha
In your file, where you have the stream, I see you have sourcmap set to true... hmm
I wonder, in your
return stream
, try updating it to this:
That should output the sourcemap in your root folder I think.
I do see you've hard coded all the locations, is there a reason it's all with the C:/... ?It was ChatGPT who wrote the whole thing. I have no idea how to write this myself haha. But yeah i also through it was kinda strange that it starts from
C:/
^^
But yeah i try this
didnt really work
did you install the sourcemaps and then imported in the file?
You mean i should run the command
npm install gulp-sourcemaps --save-dev
again?
I will try
Thank you guys, It seems to be working now, Now i have a main.css.map file 🙂do you mind sharing with us what fixed it for you?
Sure ! I just installed gulp-sourcemaps again, then i edited gulpfile.mjs to this
Then i just run "gulp" in console and it just worked. something is deprecated in gulp-sourcemaps but works anyway ^^
the documentation is awful
src() | gulp.js
Creates a stream for reading Vinyl objects from the file system.
it should work without the deprecation warning
Oh, alright thank you ! I will try this soon 🙂
good luck
Thanks ! 🙂
now im curious about if it works or not
Yeah well. To be honest i am not really 100% sure how to add this xD
Do i need to install any additional node packages?
Should i edit these paths?
Where in the code should i add this?
well, you're looking at the unimportant part of it
src
and dest
is where you should add it
and supposedly, you don't need to install any new packagesso i need to edit src and dest? Because i dont have any input/output folder in my project. So i guess i must edit thos src to my scss folder and the dest to my css folder?
yes you do
Alright 🙂
just look into
gulp.task('sass' ...
alright 🙂 Well, i will let you know when i try this. It is 05:57 here in my country so too early for me to start working on this 😂
yeah, i know what you mean