I’m trying to use Grunt as a build tool for my webapp.
I want to have at least two setups:
I. Development setup – load scripts from separate files, without concatenation,
so my index.html would look something like:
<!DOCTYPE html>
<html>
<head>
<script src="https://stackoverflow.com/questions/12401998/js/module1.js" />
<script src="js/module2.js" />
<script src="js/module3.js" />
...
</head>
<body></body>
</html>
II. Production setup – load my scripts minified & concatenated in one file,
with index.html accordingly:
<!DOCTYPE html>
<html>
<head>
<script src="https://stackoverflow.com/questions/12401998/js/MyApp-all.min.js" />
</head>
<body></body>
</html>
The question is, how can I make grunt make these index.html’s depending on the configuration when I run grunt dev
or grunt prod
?
Or maybe I’m digging in the wrong direction and it would be easier to always generate MyApp-all.min.js
but put inside it either all my scripts (concatenated) or a loader script that asynchronously loads those scripts from separate files?
How do you do it, guys?