How to watch sass and javascript at the same time in gulp 42019 Community Moderator ElectionHow to validate an email address in JavaScript?How do JavaScript closures work?How do I remove a property from a JavaScript object?How do you get a timestamp in JavaScript?How do I check if an array includes an object in JavaScript?How do I copy to the clipboard in JavaScript?How do I include a JavaScript file in another JavaScript file?How to replace all occurrences of a string in JavaScriptHow to check whether a string contains a substring in JavaScript?How do I remove a particular element from an array in JavaScript?
Is "history" a male-biased word ("his+story")?
Bash script should only kill those instances of another script's that it has launched
Why is computing ridge regression with a Cholesky decomposition much quicker than using SVD?
How did Alan Turing break the enigma code using the hint given by the lady in the bar?
How is the wildcard * interpreted as a command?
'The literal of type int is out of range' con número enteros pequeños (2 dígitos)
When traveling to Europe from North America, do I need to purchase a different power strip?
Filtering SOQL results with optional conditionals
List elements digit difference sort
How strictly should I take "Candidates must be local"?
Conservation of Mass and Energy
Do I really need to have a scientific explanation for my premise?
Latex does not go to next line
Hotkey (or other quick way) to insert a keyframe for only one component of a vector-valued property?
Was Luke Skywalker the leader of the Rebel forces on Hoth?
What Happens when Passenger Refuses to Fly Boeing 737 Max?
In the late 1940’s to early 1950’s what technology was available that could melt a LOT of ice?
PTIJ: wiping amalek’s memory?
They call me Inspector Morse
Could you please stop shuffling the deck and play already?
Are tamper resistant receptacles really safer?
Doesn't allowing a user mode program to access kernel space memory and execute the IN and OUT instructions defeat the purpose of having CPU modes?
weren't playing vs didn't play
Accepted offer letter, position changed
How to watch sass and javascript at the same time in gulp 4
2019 Community Moderator ElectionHow to validate an email address in JavaScript?How do JavaScript closures work?How do I remove a property from a JavaScript object?How do you get a timestamp in JavaScript?How do I check if an array includes an object in JavaScript?How do I copy to the clipboard in JavaScript?How do I include a JavaScript file in another JavaScript file?How to replace all occurrences of a string in JavaScriptHow to check whether a string contains a substring in JavaScript?How do I remove a particular element from an array in JavaScript?
I am trying to convert my sass to compressed-css and javascript to uglified-js. And watch
both scss and js changes
my code is working but when I tried saving a js file, it goes into a unstoppable loop.
Here is my code:
var gulp = require('gulp');
var sass = require('gulp-sass');
var uglify = require('gulp-uglify');
var concat = require('gulp-concat');
gulp.task('sass', function(done)
gulp.src('public/sass/**/*.scss')
.pipe(sass(outputStyle: 'compressed')) // Using gulp-sass
.pipe(gulp.dest('public/stylesheets'))
done();
);
gulp.task('scripts', function(done)
gulp.src('public/javascripts/**/*.js')
.pipe(concat('scripts.js'))
.pipe(uglify())
.pipe(gulp.dest('public/javascripts'))
done();
);
gulp.task('watch', function()
//I made .scss and .js into an array so they will both be watched
gulp.watch(['public/sass/**/*.scss', 'public/javascripts/**/*.js' ], gulp.series('sass', 'scripts', function(done)
done();
))
)
Now when I run gulp watch
it is working but then when I save a js file, I goes into a saving loop, It's saves and saves and saves nonstop.
I have made scss work with this code
gulp.task('watch', function()
gulp.watch('public/sass/**/*.scss', gulp.series('sass', 'scripts', function(done)
done();
))
)
But I have no idea how I can make .js files be watched.
I searched google for possible answer but only find the older version solution. Is there a way I can do this with gulp4?
- I also tried
gulp.parallel
but it still looped
Please help. Thanks
javascript gulp
add a comment |
I am trying to convert my sass to compressed-css and javascript to uglified-js. And watch
both scss and js changes
my code is working but when I tried saving a js file, it goes into a unstoppable loop.
Here is my code:
var gulp = require('gulp');
var sass = require('gulp-sass');
var uglify = require('gulp-uglify');
var concat = require('gulp-concat');
gulp.task('sass', function(done)
gulp.src('public/sass/**/*.scss')
.pipe(sass(outputStyle: 'compressed')) // Using gulp-sass
.pipe(gulp.dest('public/stylesheets'))
done();
);
gulp.task('scripts', function(done)
gulp.src('public/javascripts/**/*.js')
.pipe(concat('scripts.js'))
.pipe(uglify())
.pipe(gulp.dest('public/javascripts'))
done();
);
gulp.task('watch', function()
//I made .scss and .js into an array so they will both be watched
gulp.watch(['public/sass/**/*.scss', 'public/javascripts/**/*.js' ], gulp.series('sass', 'scripts', function(done)
done();
))
)
Now when I run gulp watch
it is working but then when I save a js file, I goes into a saving loop, It's saves and saves and saves nonstop.
I have made scss work with this code
gulp.task('watch', function()
gulp.watch('public/sass/**/*.scss', gulp.series('sass', 'scripts', function(done)
done();
))
)
But I have no idea how I can make .js files be watched.
I searched google for possible answer but only find the older version solution. Is there a way I can do this with gulp4?
- I also tried
gulp.parallel
but it still looped
Please help. Thanks
javascript gulp
add a comment |
I am trying to convert my sass to compressed-css and javascript to uglified-js. And watch
both scss and js changes
my code is working but when I tried saving a js file, it goes into a unstoppable loop.
Here is my code:
var gulp = require('gulp');
var sass = require('gulp-sass');
var uglify = require('gulp-uglify');
var concat = require('gulp-concat');
gulp.task('sass', function(done)
gulp.src('public/sass/**/*.scss')
.pipe(sass(outputStyle: 'compressed')) // Using gulp-sass
.pipe(gulp.dest('public/stylesheets'))
done();
);
gulp.task('scripts', function(done)
gulp.src('public/javascripts/**/*.js')
.pipe(concat('scripts.js'))
.pipe(uglify())
.pipe(gulp.dest('public/javascripts'))
done();
);
gulp.task('watch', function()
//I made .scss and .js into an array so they will both be watched
gulp.watch(['public/sass/**/*.scss', 'public/javascripts/**/*.js' ], gulp.series('sass', 'scripts', function(done)
done();
))
)
Now when I run gulp watch
it is working but then when I save a js file, I goes into a saving loop, It's saves and saves and saves nonstop.
I have made scss work with this code
gulp.task('watch', function()
gulp.watch('public/sass/**/*.scss', gulp.series('sass', 'scripts', function(done)
done();
))
)
But I have no idea how I can make .js files be watched.
I searched google for possible answer but only find the older version solution. Is there a way I can do this with gulp4?
- I also tried
gulp.parallel
but it still looped
Please help. Thanks
javascript gulp
I am trying to convert my sass to compressed-css and javascript to uglified-js. And watch
both scss and js changes
my code is working but when I tried saving a js file, it goes into a unstoppable loop.
Here is my code:
var gulp = require('gulp');
var sass = require('gulp-sass');
var uglify = require('gulp-uglify');
var concat = require('gulp-concat');
gulp.task('sass', function(done)
gulp.src('public/sass/**/*.scss')
.pipe(sass(outputStyle: 'compressed')) // Using gulp-sass
.pipe(gulp.dest('public/stylesheets'))
done();
);
gulp.task('scripts', function(done)
gulp.src('public/javascripts/**/*.js')
.pipe(concat('scripts.js'))
.pipe(uglify())
.pipe(gulp.dest('public/javascripts'))
done();
);
gulp.task('watch', function()
//I made .scss and .js into an array so they will both be watched
gulp.watch(['public/sass/**/*.scss', 'public/javascripts/**/*.js' ], gulp.series('sass', 'scripts', function(done)
done();
))
)
Now when I run gulp watch
it is working but then when I save a js file, I goes into a saving loop, It's saves and saves and saves nonstop.
I have made scss work with this code
gulp.task('watch', function()
gulp.watch('public/sass/**/*.scss', gulp.series('sass', 'scripts', function(done)
done();
))
)
But I have no idea how I can make .js files be watched.
I searched google for possible answer but only find the older version solution. Is there a way I can do this with gulp4?
- I also tried
gulp.parallel
but it still looped
Please help. Thanks
javascript gulp
javascript gulp
asked Mar 6 at 15:22
bradrarbradrar
1037
1037
add a comment |
add a comment |
2 Answers
2
active
oldest
votes
Your original code:
gulp.task('watch', function()
//I made .scss and .js into an array so they will both be watched
gulp.watch(['public/sass/**/*.scss', 'public/javascripts/**/*.js' ], gulp.series('sass', 'scripts', function(done)
done();
))
)
should be
gulp.task('watch', function(done)
// added done above too
gulp.watch('public/sass/**/*.scss', gulp.series('sass') )
gulp.watch('public/javascripts/**/*.js', gulp.series('scripts') )
done();
)
Your code triggers both 'sass'
and 'scripts'
tasks when either a scss or js file is modified, which is wasteful (for example, the 'sass'
task will start when a js file is altered but not actually do anything with that js file but will needlessly run the sass re-compilation although no scss file changed).
Thank you for this, I am new to gulp and all the tutorials I saw is extremely difficult to understand.
– bradrar
Mar 7 at 18:19
add a comment |
I solved this by doing this:
gulp.task('watch', function()
//I added the src folder instead of the glob **(two asterisk)
gulp.watch(['public/sass/**/*.scss', 'public/javascripts/src/*.js'], gulp.series('sass', 'scripts', function(done)
done();
))
)
I don't know why this happened but it's working now
add a comment |
Your Answer
StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);
else
createEditor();
);
function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55026517%2fhow-to-watch-sass-and-javascript-at-the-same-time-in-gulp-4%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
2 Answers
2
active
oldest
votes
2 Answers
2
active
oldest
votes
active
oldest
votes
active
oldest
votes
Your original code:
gulp.task('watch', function()
//I made .scss and .js into an array so they will both be watched
gulp.watch(['public/sass/**/*.scss', 'public/javascripts/**/*.js' ], gulp.series('sass', 'scripts', function(done)
done();
))
)
should be
gulp.task('watch', function(done)
// added done above too
gulp.watch('public/sass/**/*.scss', gulp.series('sass') )
gulp.watch('public/javascripts/**/*.js', gulp.series('scripts') )
done();
)
Your code triggers both 'sass'
and 'scripts'
tasks when either a scss or js file is modified, which is wasteful (for example, the 'sass'
task will start when a js file is altered but not actually do anything with that js file but will needlessly run the sass re-compilation although no scss file changed).
Thank you for this, I am new to gulp and all the tutorials I saw is extremely difficult to understand.
– bradrar
Mar 7 at 18:19
add a comment |
Your original code:
gulp.task('watch', function()
//I made .scss and .js into an array so they will both be watched
gulp.watch(['public/sass/**/*.scss', 'public/javascripts/**/*.js' ], gulp.series('sass', 'scripts', function(done)
done();
))
)
should be
gulp.task('watch', function(done)
// added done above too
gulp.watch('public/sass/**/*.scss', gulp.series('sass') )
gulp.watch('public/javascripts/**/*.js', gulp.series('scripts') )
done();
)
Your code triggers both 'sass'
and 'scripts'
tasks when either a scss or js file is modified, which is wasteful (for example, the 'sass'
task will start when a js file is altered but not actually do anything with that js file but will needlessly run the sass re-compilation although no scss file changed).
Thank you for this, I am new to gulp and all the tutorials I saw is extremely difficult to understand.
– bradrar
Mar 7 at 18:19
add a comment |
Your original code:
gulp.task('watch', function()
//I made .scss and .js into an array so they will both be watched
gulp.watch(['public/sass/**/*.scss', 'public/javascripts/**/*.js' ], gulp.series('sass', 'scripts', function(done)
done();
))
)
should be
gulp.task('watch', function(done)
// added done above too
gulp.watch('public/sass/**/*.scss', gulp.series('sass') )
gulp.watch('public/javascripts/**/*.js', gulp.series('scripts') )
done();
)
Your code triggers both 'sass'
and 'scripts'
tasks when either a scss or js file is modified, which is wasteful (for example, the 'sass'
task will start when a js file is altered but not actually do anything with that js file but will needlessly run the sass re-compilation although no scss file changed).
Your original code:
gulp.task('watch', function()
//I made .scss and .js into an array so they will both be watched
gulp.watch(['public/sass/**/*.scss', 'public/javascripts/**/*.js' ], gulp.series('sass', 'scripts', function(done)
done();
))
)
should be
gulp.task('watch', function(done)
// added done above too
gulp.watch('public/sass/**/*.scss', gulp.series('sass') )
gulp.watch('public/javascripts/**/*.js', gulp.series('scripts') )
done();
)
Your code triggers both 'sass'
and 'scripts'
tasks when either a scss or js file is modified, which is wasteful (for example, the 'sass'
task will start when a js file is altered but not actually do anything with that js file but will needlessly run the sass re-compilation although no scss file changed).
answered Mar 6 at 23:08
MarkMark
14.1k34058
14.1k34058
Thank you for this, I am new to gulp and all the tutorials I saw is extremely difficult to understand.
– bradrar
Mar 7 at 18:19
add a comment |
Thank you for this, I am new to gulp and all the tutorials I saw is extremely difficult to understand.
– bradrar
Mar 7 at 18:19
Thank you for this, I am new to gulp and all the tutorials I saw is extremely difficult to understand.
– bradrar
Mar 7 at 18:19
Thank you for this, I am new to gulp and all the tutorials I saw is extremely difficult to understand.
– bradrar
Mar 7 at 18:19
add a comment |
I solved this by doing this:
gulp.task('watch', function()
//I added the src folder instead of the glob **(two asterisk)
gulp.watch(['public/sass/**/*.scss', 'public/javascripts/src/*.js'], gulp.series('sass', 'scripts', function(done)
done();
))
)
I don't know why this happened but it's working now
add a comment |
I solved this by doing this:
gulp.task('watch', function()
//I added the src folder instead of the glob **(two asterisk)
gulp.watch(['public/sass/**/*.scss', 'public/javascripts/src/*.js'], gulp.series('sass', 'scripts', function(done)
done();
))
)
I don't know why this happened but it's working now
add a comment |
I solved this by doing this:
gulp.task('watch', function()
//I added the src folder instead of the glob **(two asterisk)
gulp.watch(['public/sass/**/*.scss', 'public/javascripts/src/*.js'], gulp.series('sass', 'scripts', function(done)
done();
))
)
I don't know why this happened but it's working now
I solved this by doing this:
gulp.task('watch', function()
//I added the src folder instead of the glob **(two asterisk)
gulp.watch(['public/sass/**/*.scss', 'public/javascripts/src/*.js'], gulp.series('sass', 'scripts', function(done)
done();
))
)
I don't know why this happened but it's working now
answered Mar 6 at 15:52
bradrarbradrar
1037
1037
add a comment |
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55026517%2fhow-to-watch-sass-and-javascript-at-the-same-time-in-gulp-4%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown