Conversation
Have to wait until this one is merged #158 Thanks! |
Please consider the new changes! Thanks! |
@nchanged
|
# Conflicts: # modules/fusebox-hot-reload/index.js # src/modules/fsbx-default-css-plugin/index.ts
First of all, part of config.
Notice 2 things.
The goal is to do properly HMR of Steps to reproduce incorrect behaviour, we are in dev mode
To fix this bug we need a fix - update dynamic content in hot-reload module. if (data.type === "css" && __fsbx_css) {
var newContent = `__fsbx_css(${JSON.stringify(data.path)},${JSON.stringify(data.content)})`;
FuseBox.dynamic(data.path, newContent); // will not work.
__fsbx_css(data.path, data.content)
} But solution above will not work, becase on step 4 somewhere inside of fusebox following will be called:
(function(__fbx__dnm__,exports,require,module,__filename,__dirname,__root__
/**/) {
__fsbx_css("style.scss","...")
}) To prevent this failing need (2 options):
if (data.type === "css" && __fsbx_css) {
var newContent = '(' + __fsbx_css.toString() + ')('+JSON.stringify(data.path)+', '+JSON.stringify(data.content)+')';
FuseBox.dynamic(data.path, newContent);
__fsbx_css(data.path, data.content)
} If is it ok, then one thing left - unit tests. Other point are non relevant to css plugin or hot reload. I'll create separate PR when ready. |
@nchanged ping |
So what does it do? |
|
This pull request trying to fix bugs described in #94
CssPlugin emit HMR event for non-modified files (see screenshot bug1)FuseBox.includeStyle
HMR event for RawPluginGiven
App component
Config (full file)
Bug 1
CssPlugin emit HMR event for non-modified files (
style.scss
was not modified)Bug 2
HMR does not work properly if css was converted to raw content
I know that something related to css and hmr is coming (bundle, hmr plugins etc.) maybe his fixes will be not necessary.
Please note, I've done a lot of hacks in config to fit my requirements. Maybe I'm doing it wrong.
Please review the changes.