Fix map not updating when using watch files
This commit is contained in:
parent
81d1e9ea77
commit
d798528ba6
13
dist/index.esm.js
vendored
13
dist/index.esm.js
vendored
@ -19,10 +19,15 @@ const postCSSPlugin = ({
|
|||||||
generateScopedName: "[name]__[local]___[hash:base64:5]",
|
generateScopedName: "[name]__[local]___[hash:base64:5]",
|
||||||
...typeof modules !== "boolean" ? modules : {},
|
...typeof modules !== "boolean" ? modules : {},
|
||||||
getJSON(filepath, json, outpath) {
|
getJSON(filepath, json, outpath) {
|
||||||
modulesMap.push({
|
const mapIndex = modulesMap.findIndex((m) => m.path === filepath);
|
||||||
path: filepath,
|
if (mapIndex !== -1) {
|
||||||
map: json
|
modulesMap[mapIndex].map = json;
|
||||||
});
|
} else {
|
||||||
|
modulesMap.push({
|
||||||
|
path: filepath,
|
||||||
|
map: json
|
||||||
|
});
|
||||||
|
}
|
||||||
if (typeof modules !== "boolean" && typeof modules.getJSON === "function")
|
if (typeof modules !== "boolean" && typeof modules.getJSON === "function")
|
||||||
return modules.getJSON(filepath, json, outpath);
|
return modules.getJSON(filepath, json, outpath);
|
||||||
}
|
}
|
||||||
|
|||||||
13
dist/index.js
vendored
13
dist/index.js
vendored
@ -45,10 +45,15 @@ const postCSSPlugin = ({
|
|||||||
generateScopedName: "[name]__[local]___[hash:base64:5]",
|
generateScopedName: "[name]__[local]___[hash:base64:5]",
|
||||||
...typeof modules !== "boolean" ? modules : {},
|
...typeof modules !== "boolean" ? modules : {},
|
||||||
getJSON(filepath, json, outpath) {
|
getJSON(filepath, json, outpath) {
|
||||||
modulesMap.push({
|
const mapIndex = modulesMap.findIndex((m) => m.path === filepath);
|
||||||
path: filepath,
|
if (mapIndex !== -1) {
|
||||||
map: json
|
modulesMap[mapIndex].map = json;
|
||||||
});
|
} else {
|
||||||
|
modulesMap.push({
|
||||||
|
path: filepath,
|
||||||
|
map: json
|
||||||
|
});
|
||||||
|
}
|
||||||
if (typeof modules !== "boolean" && typeof modules.getJSON === "function")
|
if (typeof modules !== "boolean" && typeof modules.getJSON === "function")
|
||||||
return modules.getJSON(filepath, json, outpath);
|
return modules.getJSON(filepath, json, outpath);
|
||||||
}
|
}
|
||||||
|
|||||||
16
src/index.ts
16
src/index.ts
@ -43,10 +43,16 @@ const postCSSPlugin = ({
|
|||||||
generateScopedName: "[name]__[local]___[hash:base64:5]",
|
generateScopedName: "[name]__[local]___[hash:base64:5]",
|
||||||
...(typeof modules !== "boolean" ? modules : {}),
|
...(typeof modules !== "boolean" ? modules : {}),
|
||||||
getJSON(filepath, json, outpath) {
|
getJSON(filepath, json, outpath) {
|
||||||
modulesMap.push({
|
// Make sure to replace json map instead of pushing new map everytime with edit file on watch
|
||||||
path: filepath,
|
const mapIndex = modulesMap.findIndex((m) => m.path === filepath);
|
||||||
map: json
|
if (mapIndex !== -1) {
|
||||||
});
|
modulesMap[mapIndex].map = json;
|
||||||
|
} else {
|
||||||
|
modulesMap.push({
|
||||||
|
path: filepath,
|
||||||
|
map: json
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
if (
|
if (
|
||||||
typeof modules !== "boolean" &&
|
typeof modules !== "boolean" &&
|
||||||
@ -62,7 +68,7 @@ const postCSSPlugin = ({
|
|||||||
// Namespace is empty when using CSS as an entrypoint
|
// Namespace is empty when using CSS as an entrypoint
|
||||||
if (args.namespace !== "file" && args.namespace !== "") return;
|
if (args.namespace !== "file" && args.namespace !== "") return;
|
||||||
|
|
||||||
// Resolve files also from node_modules (ex: npm normalize.css)
|
// Resolve files from node_modules (ex: npm install normalize.css)
|
||||||
let sourceFullPath = resolveFile(args.path);
|
let sourceFullPath = resolveFile(args.path);
|
||||||
if (!sourceFullPath)
|
if (!sourceFullPath)
|
||||||
sourceFullPath = path.resolve(args.resolveDir, args.path);
|
sourceFullPath = path.resolve(args.resolveDir, args.path);
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user