Skip to content
This repository has been archived by the owner on Jun 20, 2023. It is now read-only.

Commit

Permalink
fix: RawPlugin respects CSS dependencies for HMR (#1020)
Browse files Browse the repository at this point in the history
  • Loading branch information
ccapndave authored and nchanged committed Jan 10, 2018
1 parent 0c9d0f2 commit 4f4e367
Showing 1 changed file with 14 additions and 2 deletions.
16 changes: 14 additions & 2 deletions src/plugins/RawPlugin.ts
Expand Up @@ -2,7 +2,7 @@ import { File } from "../core/File";
import { WorkFlowContext } from "../core/WorkflowContext";
import { Plugin } from "../core/WorkflowContext";
import { utils } from "realm-utils";
import { extractExtension, string2RegExp } from "../Utils";
import { extractExtension, string2RegExp, isStylesheetExtension } from "../Utils";

export interface RawPluginOptionsObj {
extensions: string[];
Expand Down Expand Up @@ -46,9 +46,21 @@ export class RawPluginClass implements Plugin {
}
}

isRefreshRequired(file: File): boolean {
const bundle = file.context.bundle;
if (bundle && bundle.lastChangedFile) {
const lastFile = file.context.convertToFuseBoxPath(bundle.lastChangedFile);
if (isStylesheetExtension(bundle.lastChangedFile)) {
return (lastFile === file.info.fuseBoxPath ||
file.context.getItem("HMR_FILE_REQUIRED", []).indexOf(file.info.fuseBoxPath) > -1 ||
!!file.subFiles.find((subFile) => subFile.info.fuseBoxPath === bundle.lastChangedFile));
}
}
}

transform(file: File) {
const context = file.context;
if (context.useCache) {
if (context.useCache && !this.isRefreshRequired(file)) {
let cached = context.cache.getStaticCache(file);
if (cached) {
file.isLoaded = true;
Expand Down

0 comments on commit 4f4e367

Please sign in to comment.