1

As asked previously in Have Grunt include different Javascript files in development and production and Have Grunt generate index.html for different setups

I want expanded assets includes for development:

<script src="js/lib-1.js"></script>
<script src="js/lib-2.js"></script>
<script src="js/lib-3.js"></script>
...

And for production or staging:

<script src="js/all-files-in-one.js"></script>

However, I don't want to synchronize my include code in two places. For most of the available answers, I have to specify the list of files in grunt task first and then replicate the include code again in the html. The closest solution I could find is this answer: https://stackoverflow.com/a/21488659/515585, in which I only need to maintain an array of files in the grunt task. And all the answers requires a daunting amount of setup to make it work.

An even better solution would allow me to use sprocket syntax to require other asset files right in the context of the code (instead of using a build file) a la Rails asset pipeline. And expand them with a single switch of variable, so I could debug each individual file in development. I've looked at the grunt-sprockets-directives, but I don't see it offer the expanding option. Maybe it does?

I would like to not use asset pipeline from my backend framework, and I am asking for any front end build tools, not just grunt specifically. Gulp, Yeoman, or even better Broccoli.js answers are also appreciated.

Community
  • 1
  • 1
randomor
  • 5,329
  • 4
  • 46
  • 68

0 Answers0