Jigar Prajapati
Jigar Prajapati

Reputation: 83

How to minify all js files?

I have directory structure like this. How to minify all files using grunt?

I am performing grunt serve --force to my all JS files, will it minify automatically?

Upvotes: 0

Views: 671

Answers (1)

Saurabh Verma
Saurabh Verma

Reputation: 1544

You can concat all the required files and then compress like mentioned below in the config file using "concat" and "uglify",

             concat: {
                options: {
                    separator: ';'
                },
                dist: {
                    files: [{
                        src: [
                            'www/js/**/*.js'],
                        dest: 'public/js/con.js'
                    }]
                }
            },
            uglify: {
                options: {
                    banner: '/*! <%= pkg.name %> <%= grunt.template.today("yyyy-mm-dd") %> */\n'
                },
                dist: {
                    files: [{
                        src: 'public/js/con.js',
                        dest: 'public/js/con.min.js'
                    }]
                }
            }

Upvotes: 1

Related Questions