rollup-plugin-less icon indicating copy to clipboard operation
rollup-plugin-less copied to clipboard

write to file is appending and not clearing the file first.

Open jimcoolbeans opened this issue 9 years ago • 7 comments

If you set the output option to write a file the css is being appended to the existing file without clearing it first. node 6.8.1 and rollup 0.36.3

My guess would be an issue here:

                if (options.output&&isString(options.output)) {
                    if(fileCount == 1){
                        //clean the output file
                        fs.removeSync(options.output);
                    }
                    fs.appendFileSync(options.output, css);
                }

fs.removeSync isn't executing (and I think it would also throw and error if it did?).

jimcoolbeans avatar Oct 25 '16 03:10 jimcoolbeans

can you try to fixed this? it seems no propblem when I set the output to a file path.

xiaofuzi avatar Oct 27 '16 06:10 xiaofuzi

This problem can be seen when you run rollup in watch mode (rollup -c -w) When you modify the LESS file, the generated CSS file gets appended instead of being replaced.

kenfoo avatar Sep 17 '17 17:09 kenfoo

If it helps at all, I've been seeing this on Windows only. Doesn't seem to have a problem on Mac.

mienaikoe avatar Sep 25 '17 19:09 mienaikoe

in watch mode fileCount will up can't back to 0

Hi-Rube avatar Jun 20 '18 07:06 Hi-Rube

I think this is related to #24

raybooysen avatar Sep 02 '19 06:09 raybooysen

how can i insert the generate css to the head tag of an html document?i set insert as true, and output as "index.html". but the result is that the file of index.html was overwritten by generate css.

LemonGirl avatar May 20 '20 11:05 LemonGirl

I checked the code and you can force the file to be truncated when you call the plugin with watch: true parameter: less({output: out + '/app.css', watch: true})

ozooner avatar Feb 01 '21 20:02 ozooner