Browser sync isn't serving the root files












1














Browser sync isn't serving the root files using gulp.



this is my code:



 gulp.task("liveReload", [
"copy", "watch"
], function () {

browserSync.init(null,{
server: {
baseDir: ["public"]
},
files: ["*"],
port: 8080
});
gulp.watch("src/index.html").on("change",browserSync.reload);
gulp.watch("src/**/*.html").on("change",browserSync.reload);
gulp.watch(paths.srcJS, browserSync.reload);
});


I tried to play with the browser sync options and nothings works. it's only serving the subFolder files.




Is pointing the index.html but isn't serving it. which mean no liveReload occurred while changing to index.html











share|improve this question
























  • Is your copy function actually copying the files to the destination "public" folder ?
    – jmtalarn
    Nov 12 '18 at 15:16










  • @jmtalarn yes sure & The sub-folders files is working well
    – Khaled Ramadan
    Nov 12 '18 at 15:19


















1














Browser sync isn't serving the root files using gulp.



this is my code:



 gulp.task("liveReload", [
"copy", "watch"
], function () {

browserSync.init(null,{
server: {
baseDir: ["public"]
},
files: ["*"],
port: 8080
});
gulp.watch("src/index.html").on("change",browserSync.reload);
gulp.watch("src/**/*.html").on("change",browserSync.reload);
gulp.watch(paths.srcJS, browserSync.reload);
});


I tried to play with the browser sync options and nothings works. it's only serving the subFolder files.




Is pointing the index.html but isn't serving it. which mean no liveReload occurred while changing to index.html











share|improve this question
























  • Is your copy function actually copying the files to the destination "public" folder ?
    – jmtalarn
    Nov 12 '18 at 15:16










  • @jmtalarn yes sure & The sub-folders files is working well
    – Khaled Ramadan
    Nov 12 '18 at 15:19
















1












1








1







Browser sync isn't serving the root files using gulp.



this is my code:



 gulp.task("liveReload", [
"copy", "watch"
], function () {

browserSync.init(null,{
server: {
baseDir: ["public"]
},
files: ["*"],
port: 8080
});
gulp.watch("src/index.html").on("change",browserSync.reload);
gulp.watch("src/**/*.html").on("change",browserSync.reload);
gulp.watch(paths.srcJS, browserSync.reload);
});


I tried to play with the browser sync options and nothings works. it's only serving the subFolder files.




Is pointing the index.html but isn't serving it. which mean no liveReload occurred while changing to index.html











share|improve this question















Browser sync isn't serving the root files using gulp.



this is my code:



 gulp.task("liveReload", [
"copy", "watch"
], function () {

browserSync.init(null,{
server: {
baseDir: ["public"]
},
files: ["*"],
port: 8080
});
gulp.watch("src/index.html").on("change",browserSync.reload);
gulp.watch("src/**/*.html").on("change",browserSync.reload);
gulp.watch(paths.srcJS, browserSync.reload);
});


I tried to play with the browser sync options and nothings works. it's only serving the subFolder files.




Is pointing the index.html but isn't serving it. which mean no liveReload occurred while changing to index.html








javascript gulp browser-sync gulp-browser-sync






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Nov 12 '18 at 15:13

























asked Nov 12 '18 at 15:07









Khaled Ramadan

3318




3318












  • Is your copy function actually copying the files to the destination "public" folder ?
    – jmtalarn
    Nov 12 '18 at 15:16










  • @jmtalarn yes sure & The sub-folders files is working well
    – Khaled Ramadan
    Nov 12 '18 at 15:19




















  • Is your copy function actually copying the files to the destination "public" folder ?
    – jmtalarn
    Nov 12 '18 at 15:16










  • @jmtalarn yes sure & The sub-folders files is working well
    – Khaled Ramadan
    Nov 12 '18 at 15:19


















Is your copy function actually copying the files to the destination "public" folder ?
– jmtalarn
Nov 12 '18 at 15:16




Is your copy function actually copying the files to the destination "public" folder ?
– jmtalarn
Nov 12 '18 at 15:16












@jmtalarn yes sure & The sub-folders files is working well
– Khaled Ramadan
Nov 12 '18 at 15:19






@jmtalarn yes sure & The sub-folders files is working well
– Khaled Ramadan
Nov 12 '18 at 15:19














2 Answers
2






active

oldest

votes


















0














[too much for a comment]:



gulp.watch("src/index.html").on("change",browserSync.reload);
gulp.watch("src/**/*.html").on("change",browserSync.reload);


are redundant (since the globstar ** matches 0 or more directories - here you apparently have 0 directories between src and index.html). The first watch is included in the second so maybe browserSync is getting confused. Try removing the first, leaving only



gulp.watch("src/**/*.html").on("change",browserSync.reload);


and see if that helps. ** globstar docs.



Also try:



baseDir: "public"


or



baseDir: "./public"


instead of



baseDir: ["public"]





share|improve this answer























  • Hi Mark, Thanks for your answer. You are right, ("src/**/*.html") is sufficient. but brwoserSync.reload is for what the serve is listening for reloading that why doesn't solve my issue
    – Khaled Ramadan
    Nov 12 '18 at 16:35










  • But if you remove the first one ('src/index.html') does it still not work?
    – Mark
    Nov 12 '18 at 16:39










  • I remove the first line and still not work. If you got o subDir it will work well
    – Khaled Ramadan
    Nov 12 '18 at 16:45










  • See my additional suggestion in the my answer above.
    – Mark
    Nov 12 '18 at 17:04










  • Hello. Please see my answer
    – Khaled Ramadan
    Nov 13 '18 at 6:49



















0














Hello it wasn't bowser sync issue. the index.html was added after the browser sync serving. That why I gonna close this question. Thanks.






share|improve this answer





















    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
    });


    }
    });














    draft saved

    draft discarded


















    StackExchange.ready(
    function () {
    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53264961%2fbrowser-sync-isnt-serving-the-root-files%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









    0














    [too much for a comment]:



    gulp.watch("src/index.html").on("change",browserSync.reload);
    gulp.watch("src/**/*.html").on("change",browserSync.reload);


    are redundant (since the globstar ** matches 0 or more directories - here you apparently have 0 directories between src and index.html). The first watch is included in the second so maybe browserSync is getting confused. Try removing the first, leaving only



    gulp.watch("src/**/*.html").on("change",browserSync.reload);


    and see if that helps. ** globstar docs.



    Also try:



    baseDir: "public"


    or



    baseDir: "./public"


    instead of



    baseDir: ["public"]





    share|improve this answer























    • Hi Mark, Thanks for your answer. You are right, ("src/**/*.html") is sufficient. but brwoserSync.reload is for what the serve is listening for reloading that why doesn't solve my issue
      – Khaled Ramadan
      Nov 12 '18 at 16:35










    • But if you remove the first one ('src/index.html') does it still not work?
      – Mark
      Nov 12 '18 at 16:39










    • I remove the first line and still not work. If you got o subDir it will work well
      – Khaled Ramadan
      Nov 12 '18 at 16:45










    • See my additional suggestion in the my answer above.
      – Mark
      Nov 12 '18 at 17:04










    • Hello. Please see my answer
      – Khaled Ramadan
      Nov 13 '18 at 6:49
















    0














    [too much for a comment]:



    gulp.watch("src/index.html").on("change",browserSync.reload);
    gulp.watch("src/**/*.html").on("change",browserSync.reload);


    are redundant (since the globstar ** matches 0 or more directories - here you apparently have 0 directories between src and index.html). The first watch is included in the second so maybe browserSync is getting confused. Try removing the first, leaving only



    gulp.watch("src/**/*.html").on("change",browserSync.reload);


    and see if that helps. ** globstar docs.



    Also try:



    baseDir: "public"


    or



    baseDir: "./public"


    instead of



    baseDir: ["public"]





    share|improve this answer























    • Hi Mark, Thanks for your answer. You are right, ("src/**/*.html") is sufficient. but brwoserSync.reload is for what the serve is listening for reloading that why doesn't solve my issue
      – Khaled Ramadan
      Nov 12 '18 at 16:35










    • But if you remove the first one ('src/index.html') does it still not work?
      – Mark
      Nov 12 '18 at 16:39










    • I remove the first line and still not work. If you got o subDir it will work well
      – Khaled Ramadan
      Nov 12 '18 at 16:45










    • See my additional suggestion in the my answer above.
      – Mark
      Nov 12 '18 at 17:04










    • Hello. Please see my answer
      – Khaled Ramadan
      Nov 13 '18 at 6:49














    0












    0








    0






    [too much for a comment]:



    gulp.watch("src/index.html").on("change",browserSync.reload);
    gulp.watch("src/**/*.html").on("change",browserSync.reload);


    are redundant (since the globstar ** matches 0 or more directories - here you apparently have 0 directories between src and index.html). The first watch is included in the second so maybe browserSync is getting confused. Try removing the first, leaving only



    gulp.watch("src/**/*.html").on("change",browserSync.reload);


    and see if that helps. ** globstar docs.



    Also try:



    baseDir: "public"


    or



    baseDir: "./public"


    instead of



    baseDir: ["public"]





    share|improve this answer














    [too much for a comment]:



    gulp.watch("src/index.html").on("change",browserSync.reload);
    gulp.watch("src/**/*.html").on("change",browserSync.reload);


    are redundant (since the globstar ** matches 0 or more directories - here you apparently have 0 directories between src and index.html). The first watch is included in the second so maybe browserSync is getting confused. Try removing the first, leaving only



    gulp.watch("src/**/*.html").on("change",browserSync.reload);


    and see if that helps. ** globstar docs.



    Also try:



    baseDir: "public"


    or



    baseDir: "./public"


    instead of



    baseDir: ["public"]






    share|improve this answer














    share|improve this answer



    share|improve this answer








    edited Nov 12 '18 at 17:03

























    answered Nov 12 '18 at 16:09









    Mark

    11.1k33249




    11.1k33249












    • Hi Mark, Thanks for your answer. You are right, ("src/**/*.html") is sufficient. but brwoserSync.reload is for what the serve is listening for reloading that why doesn't solve my issue
      – Khaled Ramadan
      Nov 12 '18 at 16:35










    • But if you remove the first one ('src/index.html') does it still not work?
      – Mark
      Nov 12 '18 at 16:39










    • I remove the first line and still not work. If you got o subDir it will work well
      – Khaled Ramadan
      Nov 12 '18 at 16:45










    • See my additional suggestion in the my answer above.
      – Mark
      Nov 12 '18 at 17:04










    • Hello. Please see my answer
      – Khaled Ramadan
      Nov 13 '18 at 6:49


















    • Hi Mark, Thanks for your answer. You are right, ("src/**/*.html") is sufficient. but brwoserSync.reload is for what the serve is listening for reloading that why doesn't solve my issue
      – Khaled Ramadan
      Nov 12 '18 at 16:35










    • But if you remove the first one ('src/index.html') does it still not work?
      – Mark
      Nov 12 '18 at 16:39










    • I remove the first line and still not work. If you got o subDir it will work well
      – Khaled Ramadan
      Nov 12 '18 at 16:45










    • See my additional suggestion in the my answer above.
      – Mark
      Nov 12 '18 at 17:04










    • Hello. Please see my answer
      – Khaled Ramadan
      Nov 13 '18 at 6:49
















    Hi Mark, Thanks for your answer. You are right, ("src/**/*.html") is sufficient. but brwoserSync.reload is for what the serve is listening for reloading that why doesn't solve my issue
    – Khaled Ramadan
    Nov 12 '18 at 16:35




    Hi Mark, Thanks for your answer. You are right, ("src/**/*.html") is sufficient. but brwoserSync.reload is for what the serve is listening for reloading that why doesn't solve my issue
    – Khaled Ramadan
    Nov 12 '18 at 16:35












    But if you remove the first one ('src/index.html') does it still not work?
    – Mark
    Nov 12 '18 at 16:39




    But if you remove the first one ('src/index.html') does it still not work?
    – Mark
    Nov 12 '18 at 16:39












    I remove the first line and still not work. If you got o subDir it will work well
    – Khaled Ramadan
    Nov 12 '18 at 16:45




    I remove the first line and still not work. If you got o subDir it will work well
    – Khaled Ramadan
    Nov 12 '18 at 16:45












    See my additional suggestion in the my answer above.
    – Mark
    Nov 12 '18 at 17:04




    See my additional suggestion in the my answer above.
    – Mark
    Nov 12 '18 at 17:04












    Hello. Please see my answer
    – Khaled Ramadan
    Nov 13 '18 at 6:49




    Hello. Please see my answer
    – Khaled Ramadan
    Nov 13 '18 at 6:49













    0














    Hello it wasn't bowser sync issue. the index.html was added after the browser sync serving. That why I gonna close this question. Thanks.






    share|improve this answer


























      0














      Hello it wasn't bowser sync issue. the index.html was added after the browser sync serving. That why I gonna close this question. Thanks.






      share|improve this answer
























        0












        0








        0






        Hello it wasn't bowser sync issue. the index.html was added after the browser sync serving. That why I gonna close this question. Thanks.






        share|improve this answer












        Hello it wasn't bowser sync issue. the index.html was added after the browser sync serving. That why I gonna close this question. Thanks.







        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered Nov 13 '18 at 6:48









        Khaled Ramadan

        3318




        3318






























            draft saved

            draft discarded




















































            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.





            Some of your past answers have not been well-received, and you're in danger of being blocked from answering.


            Please pay close attention to the following guidance:


            • 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.




            draft saved


            draft discarded














            StackExchange.ready(
            function () {
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53264961%2fbrowser-sync-isnt-serving-the-root-files%23new-answer', 'question_page');
            }
            );

            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







            這個網誌中的熱門文章

            Tangent Lines Diagram Along Smooth Curve

            Yusuf al-Mu'taman ibn Hud

            Zucchini