Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Missing space after inline comment #1942

Closed
PinkyJie opened this issue Apr 23, 2015 · 9 comments
Closed

Missing space after inline comment #1942

PinkyJie opened this issue Apr 23, 2015 · 9 comments

Comments

@PinkyJie
Copy link

// build:css static/styles/lib.css => <!-- build:css static/styles/lib.css-->

The correct comment should be <!-- build:css static/styles/lib.css -->, notice the space after lib.css. This is a minor issue, but sometimes it can cause gulp-useref failed to inject the js/css into the html file. This issue is also reported in gulp-inject repo, see klei/gulp-inject#56

Could you consider to add a extra space after inline comment?

@shgtkshruch
Copy link

👍

@ForbesLindesay
Copy link
Member

I would accept a pull request for this.

@ForbesLindesay
Copy link
Member

Interestingly, we currently let you not put a space on either side via:

//build:css static/styles/lib.css
<!--build:css static/styles/lib.css-->

and you can put a space on both sides by adding a trailing space (I realise this is not ideal). Anything we change here would give people less control over where they put white space around comments, which makes me unsure that we should change this. It seems to me that the gulp plugins could be easily fixed.

@dwilt
Copy link

dwilt commented Jul 23, 2015

👍 I'm running into this exact issue as well. Trying to use gulp-useref and it's breaking.

Trying to do:

// build:js
// bower:js
// endbower
// endbuild

and the output is:

<!-- build:js-->
<!-- bower:js-->
<!-- endbower-->
<!-- endbuild-->

I also tried putting a trailing space behind build:js but that didn't work either. It seems to get removed when compiled.

@TimothyGu
Copy link
Member

@dwilt said:

I also tried putting a trailing space behind build:js but that didn't work either. It seems to get removed when compiled.

Can't reproduce that here

doctype
html
  head
    // build:css css/combined.css 
    link(rel='stylesheet' href='css/one.css')
    link(rel='stylesheet' href='css/two.css')
    // endbuild 
  body
    // build:js scripts/combined.js 
    script(type='text/javascript' src='scripts/one.js')
    script(type='text/javascript' src='scripts/two.js')
    // endbuild 
<!DOCTYPE html>
<html>
  <head>
    <!-- build:css css/combined.css -->
    <link rel="stylesheet" href="css/one.css">
    <link rel="stylesheet" href="css/two.css">
    <!-- endbuild -->
  </head>
  <body>
    <!-- build:js scripts/combined.js -->
    <script type="text/javascript" src="scripts/one.js"></script>
    <script type="text/javascript" src="scripts/two.js"></script>
    <!-- endbuild -->
  </body>
</html>

(example from gulp-useref)

@dwilt
Copy link

dwilt commented Jul 23, 2015

@TimothyGu Yes, I just discovered that when I put in a file path (in your example css/combined.css and scripts/combined.js), it worked. But not without it.

@PinkyJie
Copy link
Author

Putting a trailing space at the end of the line is not allowed in my editor, and I think it's not a best practice, seems the best way to fix this issue is file a issue on the repo of gulp-useref.

@TimothyGu TimothyGu added this to the 2.0.0 milestone Aug 15, 2015
@TimothyGu
Copy link
Member

seems the best way to fix this issue is file a issue on the repo of gulp-useref.

+1. Closing.

@francisrod01
Copy link

francisrod01 commented May 28, 2017

If I'm in dev environment, I don't want to combine scripts, so... I solved that with a spance after inline commented. See it below:

// bower:css (here a space after) as "// bower:css "
// endinject (here a space after)
// inject:css (here a space after)
// endinject (here a space after)

and the output is:

<!-- bower:css -->
<!-- endinject -->
<!-- inject:css -->
<!-- endinject -->

I follow the steps below and work correctly:

https://github.com/paislee/healthy-gulp-angular

Enjoy!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants