Dynamic Mapping and Concat with Grunt Uglify

后端 未结 1 1332
小蘑菇
小蘑菇 2021-01-24 10:04

I\'m trying to use dynamic mapping AND concat Javascript files with Grunt Uglify.

I have the following which is not working correctly.

Here is my folder structur

相关标签:
1条回答
  • 2021-01-24 10:54

    You can use the banner property of grunt-contrib-uglify to append the content. https://github.com/gruntjs/grunt-contrib-uglify#banner

    Here is the grunt configuration:

    grunt.initConfig({
        uglify: {
          options: {
            banner: grunt.file.read('./javascript/account/custom.js'),
            beautify: true,
            mangle: false,
            compress: false,
            preserveComments: 'all'
          },
          files: {
            expand: true,
            cwd: 'javascript/',
            src: ['bills/*.js'],
            dest: 'test/',
            ext: '.min.js',
            extDot: 'first'
          },
        }
      });

    In the above configuration every file in the bills folder will get the content of custom.js configured in the banner property.

    I hope it helps you.

    0 讨论(0)
提交回复
热议问题