Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
jimcoolbeans opened this issue Oct 25, 2016 · 7 comments
Open

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

jimcoolbeans opened this issue Oct 25, 2016 · 7 comments

Comments

@jimcoolbeans
Copy link

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
Copy link
Owner

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

@kenfoo
Copy link

kenfoo commented Sep 17, 2017

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
Copy link

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

@Hi-Rube
Copy link

Hi-Rube commented Jun 20, 2018

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

@raybooysen
Copy link

I think this is related to #24

@LemonGirl
Copy link

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
Copy link

ozooner commented Feb 1, 2021

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

8 participants