watchFiles should look for changes in all files inside sourceDir
This commit is contained in:
parent
8735128467
commit
5e3b8b69e7
20
src/index.ts
20
src/index.ts
@ -1,6 +1,12 @@
|
|||||||
import { Plugin } from "esbuild";
|
import { Plugin } from "esbuild";
|
||||||
import { Plugin as PostCSSPlugin } from "postcss";
|
import { Plugin as PostCSSPlugin } from "postcss";
|
||||||
import { ensureDir, readFile, writeFile } from "fs-extra";
|
import {
|
||||||
|
ensureDir,
|
||||||
|
readFile,
|
||||||
|
readdirSync,
|
||||||
|
statSync,
|
||||||
|
writeFile
|
||||||
|
} from "fs-extra";
|
||||||
import { TextDecoder } from "util";
|
import { TextDecoder } from "util";
|
||||||
import {
|
import {
|
||||||
SassException,
|
SassException,
|
||||||
@ -135,7 +141,7 @@ const postCSSPlugin = ({
|
|||||||
return {
|
return {
|
||||||
namespace: isModule ? "postcss-module" : "file",
|
namespace: isModule ? "postcss-module" : "file",
|
||||||
path: tmpFilePath,
|
path: tmpFilePath,
|
||||||
watchFiles: [sourceFullPath],
|
watchFiles: getFilesRecursive(sourceDir),
|
||||||
pluginData: {
|
pluginData: {
|
||||||
originalPath: sourceFullPath
|
originalPath: sourceFullPath
|
||||||
}
|
}
|
||||||
@ -199,4 +205,14 @@ function getSassImpl() {
|
|||||||
return require(impl);
|
return require(impl);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function getFilesRecursive(directory: string): string[] {
|
||||||
|
return readdirSync(directory).reduce((files, file) => {
|
||||||
|
const name = path.join(directory, file);
|
||||||
|
|
||||||
|
return statSync(name).isDirectory()
|
||||||
|
? [...files, getFilesRecursive(name)]
|
||||||
|
: [...files, name];
|
||||||
|
}, []);
|
||||||
|
}
|
||||||
|
|
||||||
export default postCSSPlugin;
|
export default postCSSPlugin;
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user