Using Fractal with webpack hotloading
See original GitHub issueOnly 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:
- Created 7 years ago
- Comments:11 (2 by maintainers)
Top 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 >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
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?
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.