From 67775ee8ec0831b15e51dc044a19700488e99246 Mon Sep 17 00:00:00 2001 From: Euan Robertson Date: Wed, 13 Jul 2022 23:13:01 +0100 Subject: [PATCH] Add all imported SASS files to the "watch" list * After every file render, grab all the includedFiles and add them all to the rollup watch list. --- src/index.ts | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/src/index.ts b/src/index.ts index 2dfa952..0731784 100644 --- a/src/index.ts +++ b/src/index.ts @@ -174,10 +174,16 @@ export = function plugin(options = {} as RollupPluginSassOptions): RollupPlugin .then(res => processRenderResponse(pluginOptions, filePath, pluginState, res.css.toString().trim()) .then(result => [res, result]) ) - .then(([res, codeResult]) => ({ - code: codeResult, - map: {mappings: res.map ? res.map.toString() : ''}, - })); // @note do not `catch` here - let error propagate to rollup level. + .then(([res, codeResult]) => { + + res.stats.includedFiles.forEach(i => {this.addWatchFile(i)}) + + return { + code: codeResult, + map: {mappings: res.map ? res.map.toString() : ''} + } + + }); // @note do not `catch` here - let error propagate to rollup level. }, generateBundle(generateOptions: { file?: string },