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

How to inject CSS without reload? What am I doing wrong? #8

Open
jamiewilson opened this issue Nov 13, 2015 · 5 comments
Open

How to inject CSS without reload? What am I doing wrong? #8

jamiewilson opened this issue Nov 13, 2015 · 5 comments
Labels

Comments

@jamiewilson
Copy link

Here's my metalsmith pipeline:

metalsmith(__dirname)
  .use(markdown())
  .use(prism())
  .use(metadata())
  .use(permalinks())
  .use(inplace())
  .use(layouts())
  .use(assets())
  .use(sass())
  .use(prefix())
  .use(uglify())
  .use(browsersync(files: [
    "layouts/**/*",
    "pages/**/*",
    "assets/**/*"
  ]))
  .build();

Any ideas? Do I need to be running browsersync in a separate pipeline branch or something?

Also, I'm not getting any file change logs, just the reload:

screen shot 2015-11-13 at 11 47 52 am

@jamiewilson
Copy link
Author

Hey @mdvorscak, did you perhaps get a chance to consider this question yet? I'm stuck :/

@mhkeller
Copy link

Does your index.html file have a <body> tag? https://browsersync.io/docs/#requirements

@jamiewilson
Copy link
Author

@mhkeller thanks for suggestion! I do have body tags in my index, and I also tried moving around some of my handlebars templates to double check and am pretty sure that's not the issue. I'm getting a the full reload, which if I recall from other projects, would break without the tag.

@smontlouis
Copy link

Hi @jamiewilson did you fix your issue ? I'm having exactly the same problem. Thank you

@a-axton
Copy link

a-axton commented Feb 15, 2017

I just quickly added this to index.js line 27 to fix

        function rebuild(event, file) {
            if (!bs.paused) {
                bs.pause();

                metalsmith.build(function(err) {
                    var buildMessage = err ? err : 'Build successful';
                    debug(buildMessage);
                    
                    bs.resume();

                    if (require('path').extname(file) === '.scss') {
                      bs.reload('*.css');
                    } else {
                      bs.reload();
                    }
                });
            }
        }

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

5 participants