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]",
|
||||
...typeof modules !== "boolean" ? modules : {},
|
||||
getJSON(filepath, json, outpath) {
|
||||
modulesMap.push({
|
||||
path: filepath,
|
||||
map: json
|
||||
});
|
||||
const mapIndex = modulesMap.findIndex((m) => m.path === filepath);
|
||||
if (mapIndex !== -1) {
|
||||
modulesMap[mapIndex].map = json;
|
||||
} else {
|
||||
modulesMap.push({
|
||||
path: filepath,
|
||||
map: json
|
||||
});
|
||||
}
|
||||
if (typeof modules !== "boolean" && typeof modules.getJSON === "function")
|
||||
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]",
|
||||
...typeof modules !== "boolean" ? modules : {},
|
||||
getJSON(filepath, json, outpath) {
|
||||
modulesMap.push({
|
||||
path: filepath,
|
||||
map: json
|
||||
});
|
||||
const mapIndex = modulesMap.findIndex((m) => m.path === filepath);
|
||||
if (mapIndex !== -1) {
|
||||
modulesMap[mapIndex].map = json;
|
||||
} else {
|
||||
modulesMap.push({
|
||||
path: filepath,
|
||||
map: json
|
||||
});
|
||||
}
|
||||
if (typeof modules !== "boolean" && typeof modules.getJSON === "function")
|
||||
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]",
|
||||
...(typeof modules !== "boolean" ? modules : {}),
|
||||
getJSON(filepath, json, outpath) {
|
||||
modulesMap.push({
|
||||
path: filepath,
|
||||
map: json
|
||||
});
|
||||
// Make sure to replace json map instead of pushing new map everytime with edit file on watch
|
||||
const mapIndex = modulesMap.findIndex((m) => m.path === filepath);
|
||||
if (mapIndex !== -1) {
|
||||
modulesMap[mapIndex].map = json;
|
||||
} else {
|
||||
modulesMap.push({
|
||||
path: filepath,
|
||||
map: json
|
||||
});
|
||||
}
|
||||
|
||||
if (
|
||||
typeof modules !== "boolean" &&
|
||||
@ -62,7 +68,7 @@ const postCSSPlugin = ({
|
||||
// Namespace is empty when using CSS as an entrypoint
|
||||
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);
|
||||
if (!sourceFullPath)
|
||||
sourceFullPath = path.resolve(args.resolveDir, args.path);
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user