I'm trying out Grunt and need a simple way to concatenate my modules

前端 未结 4 1160
星月不相逢
星月不相逢 2021-01-01 19:34

This is my first time using Grunt and I\'d like to have it combine all my js modules, each of which is wrapped in an immediately executing function, containing a \'use stric

4条回答
  •  囚心锁ツ
    2021-01-01 20:02

    I usually do it like the jQuery team does it. You create an intro.js and outro.js and put everything else in between:

    intro.js

    ;(function( window, undefined ){
      'use strict';
    

    outro.js

    }( window ));
    

    grunt.js:

    concat: {
      dist: {
        src: [
          'js/src/intro.js',
          ...
          'js/src/outro.js'
        ],
        dest: 'js/out/app.js'
      }
    }
    

提交回复
热议问题