how to minify js files in order via grunt-contrib-uglify?

后端 未结 9 2042
执念已碎
执念已碎 2021-02-01 14:51

I have a directory like below:

/folder/b.js
/folder/jQuery.js
/folder/a.js
/folder/sub/c.js

I want to minify all these js files in one js file

9条回答
  •  攒了一身酷
    2021-02-01 15:17

    If your problem was that you had vendors which needed to be loaded in order (let's say jquery before any jquery plugins). I solved it by putting jquery in its own folder called '!jquery', effectively putting it on top of the stack. Then I just used concat as you normally would:

    concat: {
      options: {
        separator: ';',
      },
      build: {
        files: [
          {
            src: ['js/vendor/**/*.js', 'js/main.min.js'],
            dest: 'js/global.min.js'
          }
        ]
      }
    },
    

提交回复
热议问题