jonkemp / gulp-useref

Parse build blocks in HTML files to replace references to non-optimized scripts or stylesheets.
MIT License
705 stars 93 forks source link

Combining all the script tags into one file does not work! #222

Closed torontom closed 7 years ago

torontom commented 7 years ago

I am gulp-useref in our project, but when I combine all the scripts that are referenced in index.html, it does not work (application could not initialize properly, and thus cannot see login page)

//this results in error when loading index.html

    <body>
     ........................
<!-- build:js scripts/combined.js -->
    <script type="text/javascript" src="path1/1.js"></script>
<script type="text/javascript" src="path2/2.js"></script>
<script type="text/javascript" src="path3/3.js"></script>
<script type="text/javascript" src="path4/4.js"></script>
<script type="text/javascript" src="path5/5.js"></script>
<script type="text/javascript" src="path6/6.js"></script>
<script type="text/javascript" src="path7/7.js"></script>
<script type="text/javascript" src="path8/8.js"></script>
<script type="text/javascript" src="path9/9.js"></script>
<script type="text/javascript" src="path10/10.js"></script>
<!-- endbuild -->
 </body> 

// the following works when I generate a few files instead of just one

 <body>
 ...............
<!-- build:js path-1/combined-1.js -->
 <script type="text/javascript" src="path1/1.js"></script>
<script type="text/javascript" src="path2/2.js"></script>
<script type="text/javascript" src="path3/3.js"></script>
<script type="text/javascript" src="path4/4.js"></script>
<!-- endbuild -->

 <!-- build:js path-2/combined-2.js -->
 <script type="text/javascript" src="path5/5.js"></script>
 <script type="text/javascript" src="path6/6.js"></script>
 <script type="text/javascript" src="path7/7.js"></script>
 <!-- endbuild -->

  <!-- build:js path-3/combined-3.js -->
  <script type="text/javascript" src="path8/8.js"></script>   
  <script type="text/javascript" src="path9/9.js"></script>
  <script type="text/javascript" src="path10/10.js"></script>
  <!-- endbuild -->
  </body>

After this, I use gulp-concat to combine the few files generated from above, and update the reference in index.html, and worked... but I wonder why... I want to do it in one step... anyone also encountered this?

torontom commented 7 years ago

It seems it's not a problem of gulp-useref, but something else I haven't figured out...