Skip to content

Commit

Permalink
Merge pull request #24 from def-studio/fix-tailwind-not-updating
Browse files Browse the repository at this point in the history
[chore] refactor tailwind update code
  • Loading branch information
fabio-ivona authored Aug 26, 2022
2 parents f5944b5 + f3c9590 commit 63977ac
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 14 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@defstudio/vite-livewire-plugin",
"version": "0.2.5",
"version": "0.2.6",
"author": {
"name": "Fabio Ivona"
},
Expand Down
16 changes: 3 additions & 13 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -245,32 +245,22 @@ export default function livewire(config?: PluginConfig | string | string[]): Liv

for (const pattern of pluginConfig.watch) {
if (minimatch(ctx.file, pattern)) {

//Fix unwanted full reloads
if (ctx.modules[0]?.importers && ctx.modules[0].importers.size === 1) {
const dummyModule = {...ctx.modules[0]};
dummyModule.importers = new Set;
dummyModule.isSelfAccepting = true;
ctx.modules[0].importers.add(dummyModule);
}


const refreshList = [...pluginConfig.refresh.filter(path => {
if(ctx.modules.length === 0 || !ctx.modules[0]){
return true
}


let includeInRefresh = true;
ctx.modules[0].importers.forEach(importer => {
includeInRefresh = importer.file?.endsWith(path) ?? false;
includeInRefresh = !importer.file?.endsWith(path) ?? false;
});
return includeInRefresh;
})];

triggerUpdates(ctx, refreshList);

refresh(ctx, pluginConfig)

return [...ctx.modules[0]?.importers ?? [], ...ctx.modules.slice(1)];
}
}
}
Expand Down

0 comments on commit 63977ac

Please sign in to comment.