How to merge into a file already minified with Grunt-contrib-uglify

Asked

Viewed 224 times

5

Here’s the situation, I’m using the Grunt-contrib-uglify to minify my project’s javascript into a single file, the problem is that one of these files is already minified, and the uglify does not add it to my destination file, causing syntax error in the project.

The question would be, is there any way to do the Grunt-contrib-uglify at least copy the file already minified and join with others in the final file?

The code of my Gruntfile.js is:

module.exports = function(grunt) {
    grunt.initConfig({
        pkg: grunt.file.readJSON('package.json'),
        skinPath: './skin/frontend/default/<%= pkg.name %>',
        cssmin: {
            combine: {
                files: {
                    '<%= skinPath %>/css/vendor.min.css': [
                        '<%= skinPath %>/css/bootstrap.css',
                        '<%= skinPath %>/css/bootstrap-responsive.css',
                        '<%= skinPath %>/magentothem/**/*.css'
                    ],
                    '<%= skinPath %>/css/styles.min.css': [
                        '<%= skinPath %>/css/styles.css',
                        '<%= skinPath %>/css/widgets.css',
                    ],
                    '<%= skinPath %>/css/print.min.css': [ '<%= skinPath %>/css/print.css' ],
                    '<%= skinPath %>/css/styles-ie.min.css': [ '<%= skinPath %>/css/styles-ie.css' ],
                    '<%= skinPath %>/css/styles-ie8.min.css': [ '<%= skinPath %>/css/styles-ie8.css' ],
                }
            }
        },
        uglify: {
            options: {
                preserveComments: 'all'
            },
            supimpa: {
                src: [
                    './js/prototype/prototype.js',
                    './js/lib/ccard.js',
                    './js/prototype/validation.js',
                    './js/scriptaculous/builder.js',
                    './js/scriptaculous/effects.js',
                    './js/scriptaculous/dragdrop.js',
                    './js/scriptaculous/controls.js',
                    './js/scriptaculous/slider.js',
                    './js/varien/js.js',
                    './js/varien/form.js',
                    './js/varien/menu.js',
                    './js/mage/translate.js',
                    './js/mage/cookies.js',
                    './js/magentothem/ma.jq.slide.js'
                    './js/magentothem/ma.flexslider.js',
                    './js/magentothem/jquery-ui.js'
                ],
                dest: './js/supimpa.min.js'
            }
        },
    });

    grunt.loadNpmTasks('grunt-contrib-uglify');
    grunt.loadNpmTasks('grunt-contrib-cssmin');

    grunt.registerTask('default', ['cssmin', 'uglify']);

};

Whereas ./js/magentothem/ma.jq.slide.js is already minified, and because of this as I explained earlier is not added in the file ./js/supimpa.min.js.

Is there any option or method to do it at least add the code in the final file?

  • Make any difference which of them will come first in the final file?

  • Unfortunately it does, the file ma.jq.slide.js contains the minified Jquery along with some changes, that the files ma.flexslider.js and jquery-ui.js make use of.

  • Are you sure uglify doesn’t put the file together because it’s minified? I’d say it’s a path problem or something... you’ve got it on Github so I can test?

  • Worst I don’t have on github @Sergio, it’s a magento project.

  • Now seeing here, it is adding correctly, I think the problem is syntax even @Sergio

  • Ok, in this case and if it works it puts an answer indicating what was wrong and how you solved it. So it may be useful to others.

  • Blz, even so vlw by the provision in help!

  • Use a task only to concatenate would not be better than using a task with two roles?

  • This is the thing, but first I have to minify the ones that are not minnified :D

Show 4 more comments

1 answer

1

Browser other questions tagged

You are not signed in. Login or sign up in order to post.