Gulp-useref is throwing error: “path must be a string”

前端 未结 1 1166
梦如初夏
梦如初夏 2021-01-27 00:35

I\'m using a gulpfile.js generated by yeoman\'s gulp-webapp generator and modified slightly by me to fit my needs. For some reason I keep running into an issue when

1条回答
  •  孤独总比滥情好
    2021-01-27 01:03

    Short answer: TypeError: path must be a string means that there is an issue with the link/script paths. useref can't find the the file or directory you are pointing it to.

    Long answer:
    There were two issues I ran into.

    1. The link/script paths needs to be relative to the gulpfile or have an alternate directory to search.
    
    
    
    
    

    OR

    
    
    
    
    
    1. The yeoman gulpfile uses multiple alt directories which requires you to put them inside curly braces like this:
     Works
    

    But if you only have one alt directory and you leave it in the curly braces it will throw an error.

     TypeError: path must be a string
    

    This is because it is reading the path as C:\path\to\project\{app}\styles\style.css. This seems like odd behavior to me. I would think that it would iterate through the directories listed in the braces regardless of the length.

    0 讨论(0)
提交回复
热议问题