Concat and Uglify JS Files from Two Different Sources using Grunt

kaoscify

I have different sets of JS files that I want to concat and uglify. One is for the app, one is for the website. My gruntfile.js looks something like the one below. The problem is that only the website one runs even though I have registered the grunt task as: grunt.registerTask('default', ['concat:app', 'concat:website', 'uglify']);

concat: {
    app: {
        js: {
            src: [
            'app/js/vendor/jquery.js',
            'app/js/app/ui.js',
            'app/js/app/data.js'
        ],
            dest: 'app/js/app.js'
        },
        css: {
            src: [
            'app/css/vendor/normalize.css',
            'app/css/vendor/ui.css',
            'app/css/vendor/style.css',
        ],
            dest: 'app/css/app.css'
        }
    },
    website: {
        src: [
            'app/js/vendor/jquery.js',
            'app/js/website/scripts.js'
        ],
        dest: 'app/js/common.js'
    }
},
uglify: {
    development: {
        options: {
            preserveComments: false
        },
        files: {
            'app/js/app.min.js': 'app/js/app.js',
            'app/js/common.min.js': 'app/js/common.js'
        }
    }
}
Xavier Priour

concat can concatenate multiple files and types in the same target, but you have to use the proper grunt syntax (https://www.npmjs.com/package/grunt-contrib-concat#multiple-files-per-target):

concat: {
  app: {
    'app/js/app.js': [
        'app/js/vendor/jquery.js',
        'app/js/app/ui.js',
        'app/js/app/data.js'
    ],
    'app/css/app.css': [
        'app/css/vendor/normalize.css',
        'app/css/vendor/ui.css',
        'app/css/vendor/style.css',
    ],
  }
},

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

grunt uglify from two source files

From Dev

Combine js files from different directories via config using grunt

From Dev

Grunt concat + uglify with sourcemaps

From Dev

JS use a function from two different sources

From Dev

Using Grunt uglify task to mangle JS code

From Dev

Using Grunt to concat multiple js files but want them split?

From Dev

Grunt uglify not finding files

From Dev

Grunt concat files on a different domain or on different server

From Dev

Dynamic Mapping and Concat with Grunt Uglify

From Dev

Invoking grunt concat two times with different options

From Dev

How to use grunt-contrib-uglify to gzip the js files also?

From Dev

Is it possible to only minify unminified JS files with grunt uglify

From Dev

grunt: how to detect if file is saved to uglify all of my js files

From Dev

How to uglify all javascript files in subfolders/subdirectory using Grunt?

From Dev

How to uglify all javascript files in subfolders/subdirectory using Grunt?

From Dev

Grunt concat html and js with different separators?

From Dev

Grunt - Concat multiple JS files and watch for changes

From Dev

Grunt - Concat multiple JS files and watch for changes

From Dev

JS files getting duplicate in Grunt concat task

From Dev

How to ignore files grunt uglify

From Dev

Angularjs minification using grunt uglify resulting in js error

From Dev

Angularjs minification using grunt uglify resulting in js error

From Dev

firefox unresponsive script after grunt concat/uglify

From Dev

Troubleshoot Grunt concat and Uglify in Sails pipeline

From Dev

Gulp, concat and uglify files and concat with vendor

From Dev

grunt-open for two different files

From Dev

Using grunt to concat many files from many dirs into single renamed file in new directory

From Dev

Grunt Uglify - Ignore Specific Files/Folders

From Dev

Grunt uglify - Update src after combining files

Related Related

  1. 1

    grunt uglify from two source files

  2. 2

    Combine js files from different directories via config using grunt

  3. 3

    Grunt concat + uglify with sourcemaps

  4. 4

    JS use a function from two different sources

  5. 5

    Using Grunt uglify task to mangle JS code

  6. 6

    Using Grunt to concat multiple js files but want them split?

  7. 7

    Grunt uglify not finding files

  8. 8

    Grunt concat files on a different domain or on different server

  9. 9

    Dynamic Mapping and Concat with Grunt Uglify

  10. 10

    Invoking grunt concat two times with different options

  11. 11

    How to use grunt-contrib-uglify to gzip the js files also?

  12. 12

    Is it possible to only minify unminified JS files with grunt uglify

  13. 13

    grunt: how to detect if file is saved to uglify all of my js files

  14. 14

    How to uglify all javascript files in subfolders/subdirectory using Grunt?

  15. 15

    How to uglify all javascript files in subfolders/subdirectory using Grunt?

  16. 16

    Grunt concat html and js with different separators?

  17. 17

    Grunt - Concat multiple JS files and watch for changes

  18. 18

    Grunt - Concat multiple JS files and watch for changes

  19. 19

    JS files getting duplicate in Grunt concat task

  20. 20

    How to ignore files grunt uglify

  21. 21

    Angularjs minification using grunt uglify resulting in js error

  22. 22

    Angularjs minification using grunt uglify resulting in js error

  23. 23

    firefox unresponsive script after grunt concat/uglify

  24. 24

    Troubleshoot Grunt concat and Uglify in Sails pipeline

  25. 25

    Gulp, concat and uglify files and concat with vendor

  26. 26

    grunt-open for two different files

  27. 27

    Using grunt to concat many files from many dirs into single renamed file in new directory

  28. 28

    Grunt Uglify - Ignore Specific Files/Folders

  29. 29

    Grunt uglify - Update src after combining files

HotTag

Archive