question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Using Fractal with webpack hotloading

See original GitHub issue

Only been using Fractal for a couple of days but man, I’m so in love. I think this is the best pattern generation tool out there.

I love how bare bones it is compared to the others out there.

So I typically run BrowserSync over the top of an application to give me Sass and JS change injection via Gulp Sass and Webpack. The Sass stuff was easy because it produces a CSS file into a directory but hotloading works a little differently.

This is how I usually integrate webpack with my Browsersync instance. Have tried replacing Browsersync with Fractal instances without much luck, I always get a 404 on my JS.

if(global.production) return

var browserSync       = require('browser-sync')
var gulp              = require('gulp')
var webpack           = require('webpack')
var webpackMultiConfig = require('../lib/webpack-multi-config')
var config            = require('../config')
var pathToUrl         = require('../lib/pathToUrl')

var browserSyncTask = function() {

  var webpackConfig = webpackMultiConfig('development')
  var compiler = webpack(webpackConfig)
  var proxyConfig = config.tasks.browserSync.proxy || null;

  if (typeof(proxyConfig) === 'string') {
    config.tasks.browserSync.proxy = {
      target : proxyConfig
    }
  }

  var server = config.tasks.browserSync.proxy || config.tasks.browserSync.server;

  server.middleware = [
    require('webpack-dev-middleware')(compiler, {
      stats: 'errors-only',
      publicPath: pathToUrl('/', webpackConfig.output.publicPath)
    }),
    require('webpack-hot-middleware')(compiler)
  ]

  browserSync.init(config.tasks.browserSync)
}

gulp.task('browserSync', browserSyncTask)
module.exports = browserSyncTask

Has anyone managed anything similar?

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Comments:11 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
simondibcommented, Jan 23, 2017

hey @stevieg83 or @johannestroeger have either of you successfully got Webpack’s HMR working with Gulp/Fractal? I’m almost there but each time Webpack recompiles the bundle it’s instead reloading the whole page and therefore losing the HMR instance. Any ideas?

0reactions
stale[bot]commented, Jul 12, 2018

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Hot Module Replacement - webpack
This guide extends on code examples found in the Development guide. Hot Module Replacement (or HMR) is one of the most useful features...
Read more >
fractal-webpack-plugin - npm
Fractal webpack plugin to easily integrate fractal into a webpack workflow. Requires webpack 4 or 5. Installation. npm install fractal-webpack- ...
Read more >
Setting Up DevServer With Hot Reloading Using WebPack 4 ...
The next command I run will install the latest version of WebPack which is version 4, WebPack CLI, Web Pack Dev Server, and...
Read more >
Integrate Fractal with Webpack Encore - Clemens Krack
I am often using Fractal to handle my component libraries. I don't always want to keep a completely separate project, so I was...
Read more >
Hot reloading not working on React project with Webpack 5
What worked for me in the end is adding the following plug-in:'@pmmmwh/react-refresh-webpack-plugin'. Here is the webpack.config.js file ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found