Compare commits
1 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
fb0d9eac15 |
12
src/index.ts
12
src/index.ts
@ -87,6 +87,7 @@ const postCSSPlugin = ({
|
|||||||
const sourceRelDir = path.relative(path.dirname(rootDir), sourceDir);
|
const sourceRelDir = path.relative(path.dirname(rootDir), sourceDir);
|
||||||
const isModule = sourceBaseName.match(/\.module$/);
|
const isModule = sourceBaseName.match(/\.module$/);
|
||||||
const tmpDir = path.resolve(tmpDirPath, sourceRelDir);
|
const tmpDir = path.resolve(tmpDirPath, sourceRelDir);
|
||||||
|
const watchFiles = [sourceFullPath];
|
||||||
|
|
||||||
let tmpFilePath = path.resolve(
|
let tmpFilePath = path.resolve(
|
||||||
tmpDir,
|
tmpDir,
|
||||||
@ -103,10 +104,11 @@ const postCSSPlugin = ({
|
|||||||
let css = sourceExt === ".css" ? fileContent : "";
|
let css = sourceExt === ".css" ? fileContent : "";
|
||||||
|
|
||||||
// parse files with preprocessors
|
// parse files with preprocessors
|
||||||
if (sourceExt === ".sass" || sourceExt === ".scss")
|
if (sourceExt === ".sass" || sourceExt === ".scss") {
|
||||||
css = (
|
let result = await renderSass({ ...sassOptions, file: sourceFullPath })
|
||||||
await renderSass({ ...sassOptions, file: sourceFullPath })
|
css = result.css.toString();
|
||||||
).css.toString();
|
watchFiles.push(...result.stats.includedFiles);
|
||||||
|
}
|
||||||
if (sourceExt === ".styl")
|
if (sourceExt === ".styl")
|
||||||
css = await renderStylus(new TextDecoder().decode(fileContent), {
|
css = await renderStylus(new TextDecoder().decode(fileContent), {
|
||||||
...stylusOptions,
|
...stylusOptions,
|
||||||
@ -135,7 +137,7 @@ const postCSSPlugin = ({
|
|||||||
return {
|
return {
|
||||||
namespace: isModule ? "postcss-module" : "file",
|
namespace: isModule ? "postcss-module" : "file",
|
||||||
path: tmpFilePath,
|
path: tmpFilePath,
|
||||||
watchFiles: [sourceFullPath],
|
watchFiles,
|
||||||
pluginData: {
|
pluginData: {
|
||||||
originalPath: sourceFullPath
|
originalPath: sourceFullPath
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user