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

Can useref extract script and style from html tag to output file? #260

Closed YanxinTang closed 2 years ago

YanxinTang commented 4 years ago

I want to bundle js files and internal scripe tag content to onefile by gulp-useref. But according to the test result that gulp-useref can't do this.

Example:

The configuration of gulp-useref using default value.

<html>
    <!-- build:js js/bundle.js -->
    <script src="a.js"></script>
    <script>
      console.log('hello')
    </script>
    <!-- endbuild -->
</html>

The actual output likes this:

<html>
    <script src="js/bundle.js"></script>
</html>

js/bundle.js content:

// a.js content

It seems that useref omit the internal script.

But I want the content of bundle.js should like this: js/bundle.js content:

// a.js content
console.log('hello')

Can I achieve this only use gulp-useref or with other plugins?