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

Overwriting existing minified file? #83

Closed
norfali opened this issue Mar 19, 2014 · 14 comments
Closed

Overwriting existing minified file? #83

norfali opened this issue Mar 19, 2014 · 14 comments

Comments

@norfali
Copy link

norfali commented Mar 19, 2014

When I run grunt cssmin, it works great by writing a new file style.min.css.

However if I run cssmin again, instead of overwriting the contents of style.min.css as expected, it seems to append instead.

This sounds like a bug but happy to be corrected!

@vladikoff
Copy link
Member

Can't reproduce. You need to show us your config.
This can easily be tested by removing clean from out tests: https://github.com/gruntjs/grunt-contrib-cssmin/blob/master/Gruntfile.js#L84
and rerunning the tests multiple times.

@jeffmcmahan
Copy link

Same issue here. The output file grows longer each time.

Any luck with this @norfali ?

EDIT: Seems to have been a version conflict in my environment. Resolved now.

EDIT 2: No, I take that back. It's still doing it. Just not every time. This is weird.

@jeffmcmahan
Copy link

Update: Doesn't happen with a single source file. Only when there are multiple .styl source files.

In my case, the task is [ 'stylus', 'cssmin', 'clean:stylesheets' ]

Stylus and cssmin are latest.

@norfali
Copy link
Author

norfali commented Apr 16, 2014

Yep @jeffmcmahan - issue still occurs. The workaround was to add clean plugin for erasing files before cssmin runs. My config:


   clean: ['your_path/css/*.min.css', '!your_path/css/*.css'],
   cssmin: {
      minify: {
        expand: true,
        cwd: 'your_path/css/',
        src: ['*.css'],
        dest: 'your_path/css/',
        ext: '.min.css'
      }
    }

A task:

grunt.registerTask('minify', ['clean', 'cssmin']);

Worked well for me - hope this helps :)

@vladikoff vladikoff reopened this Apr 16, 2014
@vladikoff
Copy link
Member

Reopened the issue. This is strange, as I mentioned earlier I ran the tests without clean and the output was fine.
What OS are you guys on @norfali @jeffmcmahan ?

@norfali
Copy link
Author

norfali commented Apr 16, 2014

Am on Windows 7.

@vladikoff
Copy link
Member

Ok I will look into this on Windows in the next few days and will let you know

@jeffmcmahan
Copy link

I'm using OSX 10.9.2. Latest Node.js, and latest grunt-contrib-clean, too.

@norfali
Copy link
Author

norfali commented Apr 16, 2014

Strange. Long shot but what file sizes are your CSS? Also how many lines?

@jeffmcmahan
Copy link

Very small, in my case. Fewer than 200 lines.

@vladikoff
Copy link
Member

@norfali in your configuration have you tried changing:
src: ['*.css'], to src: ['*.css', '!*.min.css'].

@jeffmcmahan what is your configuration?

@jeffmcmahan
Copy link

I'm was compiling many-to-one, as follows:

  cssmin: {
      build: {
        files: {
          'demo/build/matte.min.css': [ 'demo/build/**/*.min.css' ]
        }
      }
    }

But I see the sensible way to do that is, this:

cssmin: {
  combine: {
    files: {
      'path/to/output.css': ['path/to/input_one.css', 'path/to/input_two.css']
    }
  }
}

... and that solved my problem. No bug in my case.

@rubyisapm
Copy link

If two files have the same part,the combined file will repeated those code.I wonder how to deal with it?

@vladikoff
Copy link
Member

'demo/build/matte.min.css': [ 'demo/build/**/*.min.css' ] have to be careful with this pattern. It will take the files that it made and use them again.
Use --verbose to see which files are used in INPUT -> OUTPUT.

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

4 participants