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

TypeError: Cannot read property 'replace' of undefined #240

Open shooftie opened 6 years ago

shooftie commented 6 years ago

I have tried everything and despite an irksome feeling that it is my incompetence I am at a loss.

I have the folder structure:

dist/
app/
    |- js/
        main.js
        plugins.js
    |- embeds/
        footer.php

footer.php looks like this:

        <footer class="body-footer">
            <p>&copy; My site 2017</p>
        </footer>
        <!--build:js js/main.js -->
        <script src="../js/plugins.js"></script>
        <script src="../js/main.js"></script>
        <!-- endbuild -->
    </body>
</html>

My gulp task looks like this:

gulp.task('useref', function () {
    return gulp.src('app/embeds/footer.php')
        .pipe(useref())
        .pipe(gulp.dest('dist'))
});

I keep getting this error:

TypeError: Cannot read property 'replace' of undefined
at module.exports (/my-project/repo/node_modules/useref/lib/getBlocks.js:31:19)
at module.exports (/my-project/repo/node_modules/useref/index.js:8:16)
at Gulp.<anonymous> (/my-project/repo/gulpfile.js:108:15)
at module.exports (/my-project/repo/node_modules/orchestrator/lib/runTask.js:34:7)
at Gulp.Orchestrator._runTask (/my-project/repo/node_modules/orchestrator/index.js:273:3)
at Gulp.Orchestrator._runStep (/my-project/repo/node_modules/orchestrator/index.js:214:10)
at Gulp.Orchestrator.start (/my-project/repo/node_modules/orchestrator/index.js:134:8)
at /usr/local/lib/node_modules/gulp-cli/lib/versioned/^3.7.0/index.js:46:20
at _combinedTickCallback (internal/process/next_tick.js:67:7)
at process._tickCallback (internal/process/next_tick.js:98:9)
jonkemp commented 6 years ago

Haha, this is really late but it looks like useref is not getting the content from footer.php.