xiaofuzi / rollup-plugin-less

a less rollup plugin
22 stars 24 forks source link

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

Open jimcoolbeans opened 8 years ago

jimcoolbeans commented 8 years ago

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?).

xiaofuzi commented 8 years ago

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

kenfoo commented 7 years ago

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.

mienaikoe commented 7 years ago

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

Hi-Rube commented 6 years ago

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

raybooysen commented 5 years ago

I think this is related to #24

LemonGirl commented 4 years ago

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.

ozooner commented 3 years ago

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})