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

Browsersync double reload #134

Open
allmarkedup opened this issue Aug 22, 2016 · 5 comments
Open

Browsersync double reload #134

allmarkedup opened this issue Aug 22, 2016 · 5 comments

Comments

@allmarkedup
Copy link
Member

Double reload occurs when changing an asset file within the components directory that also gets compiled into the public directory. Need a way of filtering out files types to prevent this happening.

@emolr
Copy link

emolr commented Feb 14, 2018

For others who can't seem to get this option working.

The double reload occurs when files referenced as public using the fractal.web.set('static.path', path.join(__dirname, 'dist')); is used within templates and a build tool like webpack updated the dist folder.

To prevent this, ignore the auto generated files all together :)

this snippet works for me in fractal.js:

fractal.web.set('server.syncOptions', {
    watchOptions: {
        ignored: path.resolve('dist/**/*'),
    },
});

It's important to add the **/* to dist, and to use path.resolve.

It's a bit mysterious to me why anymatch (used for matching) doesn't match on just dist without path resolve, but i guess it's the context the program is running from :)

@emolr
Copy link

emolr commented Feb 14, 2018

@allmarkedup

Do you think it would be a good idea to add Path.resolve to the server.js ignore function like this:

const ignored = bsConfig.watchOptions.ignored ? anymatch(Path.resolve(bsConfig.watchOptions.ignored)) : () => false;

It should be backward compatible for those who already used path.resolve :)

@julkue
Copy link

julkue commented Apr 16, 2020

Still need this.

@sidouglas
Copy link

I have spent the weekend ( nearly all of it ) figuring this out (and bunch of other requirements). I have made a little quick start project that extends the one that is generated by fractal-cli.
Check the fractaServer/browserSync.js file
https://github.com/sidouglas/fractal-quickstart

@julkue
Copy link

julkue commented Feb 11, 2021

I found out that anymatch – that is being used to compare the passed ignore paths by Fractal – doesn't seem to be able to compare a path with Windows backslashes with a Unix path correctly. Thus, I had to use slash to convert the path before passing it to Fractal:

const slash = require('slash');

  fractal.web.set('server.syncOptions', {
    watchOptions: {
      ignored: [
        slash(path.join(__dirname, '../src/**/*.scss')),
        slash(path.join(__dirname, '../src/**/*.js')),
      ]
    }
  });

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

No branches or pull requests

4 participants