Вопрос

I need to write an advanced concat script using grunt. here is my boilerplate:

___js
|____dist
| |____vents
| | |____commonEvents.js
| | |____compare.js
|____libs
|____src
| |____events
| | |____carousel.common.js
| | |____compare.js
| | |____styles.common.js
| |____handlers
| | |____carousel.common.js
| | |____compare.js
| | |____style.common.js

I want the concat task to look into "src/events" and "src/handlers" directory and find all the files ending with ".common.js" and concat them together and put them in the "dist/vents" directory ("commonEvents.js"), other files that are not ending with ".common.js" I want the script to find the pair in the other directory and concat them together and put them into "dis/vents/filename.js" (example: events/compare.js and handlers/compare.js are pair and not ending with common.js).

Это было полезно?

Решение

I guess that we already know about https://github.com/gruntjs/grunt-contrib-concat module. You just need two different tasks. What about this:

grunt.initConfig({
  concat: {
    common: {
      src: ['src/events/**/*.common.js', 'src/handlers/**/*.common.js'],
      dest: 'dist/vents/commonEvents.js'
    },
    nocommon: {
      src: ['src/events/**/*.js', 'src/handlers/**/*.js', '!src/events/**/*.common.js', '!src/handlers/**/*.common.js'],
      dest: 'dist/vents/filename.js'
    }
  }
});

Другие советы

I don't think there is anything similar ready to use.

If you plan to create your own solution, I think this package can be a good starting point:

https://github.com/yeoman/grunt-usemin

It manipulates the config of other plugins as well.

Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top