grunt-assemble icon indicating copy to clipboard operation
grunt-assemble copied to clipboard

assets path malfunction

Open ain opened this issue 8 years ago • 5 comments

Steps to reproduce:

  1. Add CSS file to app/styles/main.css

  2. Create index.hbs with:

    <!-- build:css(.tmp) {{assets}}styles/main.css -->
    <link rel="stylesheet" href="{{assets}}styles/main.css" type="text/css" media="all">
    <!-- endbuild --> 
    
  3. Create Gruntfile with path of assets and dest set to app/

  4. Compile

What happens: index.html comes across with

    <!-- build:css(.tmp) ..styles/main.css -->
    <link rel="stylesheet" href="..styles/main.css" type="text/css" media="all">
    <!-- endbuild -->

What should happen: valid relative path, e.g. styles/main.css or ./styles/main.css.

ain avatar Jul 14 '16 13:07 ain

@ain Thanks for the issue! If you're reporting a bug, please be sure to include:

  • The version of assemble you are using.
  • Your assemblefile.js (This can be in a gist)
  • The commandline output. (Screenshot or gist is fine)
  • What you expected to happen instead.

assemblebot avatar Jul 14 '16 13:07 assemblebot

You're missing a slash in your template after {{assets}}

jonschlinkert avatar Jul 19 '16 20:07 jonschlinkert

@jonschlinkert I'm calling to reopen this ticket. As described, the configuration had the slash:

assemble: {
  options: {
    flatten: true,
    layoutext: '.hbs',
    assets: './app/'
  }
}

What it gives me is:

<script src="..scripts/vendor.js"></script>

Also, if I move slash from the config to the template, it gives me

<script src="../scripts/vendor.js"></script>

but it should be

<script src="./scripts/vendor.js"></script>

So the assets path calculation is certainly invalid here.

ain avatar Apr 28 '17 13:04 ain

I was able to resolve the issue by duplicating the assets path!

assets: '<%= config.app %>/<%= config.app %>'

This pretty much reproduces the issue. I'm reopening the ticket.

ain avatar Apr 28 '17 13:04 ain

We can look into this, but it seems more likely that something is wrong in your config or templates, otherwise we would have gotten other issues about this by now.

Or maybe there is a bug with some combination of things that isn't common?

Can you provide the minimum necessary setup for us to reproduce the bug?

jonschlinkert avatar Apr 28 '17 21:04 jonschlinkert