question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

How to specify different relative assets path

See original GitHub issue

Related to this feature request: https://github.com/jonkemp/gulp-useref/issues/106

I have this folder structure:

app
---- js
-------- script.js
---- html
-------- index.html

But instead useref compiles my assets (js) inside the html folder and I’m looking for an option to specify a different relative path for the assets.

useref html block code:

<!-- build:js /app/js/script.js -->
<script src="..\js\script1.js" async></script>
<script src="..\js\script2.js" async></script>
<!-- endbuild -->

Useref correctly replaces the path in the compiled html file of the js assets with /app/js/script.js but as written above, doesn’t compile in the correct folder the assets (that is not app/html/app/js/script.js but app/js/script.js). The option needed should be like “outputRelativePath” of gulp-usemin

Thanks for attention

Issue Analytics

  • State:closed
  • Created 8 years ago
  • Comments:10 (4 by maintainers)

github_iconTop GitHub Comments

2reactions
nathanredblurcommented, Apr 12, 2016

I have an scenario a little different.

dist/
  |-public/
    |-scripts/
  |-server
    |-view/
      |-file.jade

file.jade

<!-- build:js({client,node_modules}) scripts/client.js -->
.
.
<!-- endbuild -->

and gulp task

gulp.task('build:client', () => {
  return gulp.src('dist/server/view/file.jade', {base: 'dist'})
      .pipe(useref())
      .pipe(gulp.dest('dist'));
});

On run, gulp overwrite my file correctly 😄

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

But the file is create in the same path 😢 dist/scripts/client.js and I can find a way to put on the compile file in the right path dist/public/scripts/client.js

I try to set base, but I’m sure that is not the way. I need some opton that let me prefix the save path that come from “useref”.

Some Ideas?

0reactions
nathanredblurcommented, Mar 22, 2017

I fix this, I don’t remember well how but I think that was something like this.

gulp.task('build:client', () => {
  return gulp.src('dist/server/view/file.jade', {base: 'dist/public'})
      .pipe(useref())
      .pipe(gulp.dest('dist/public'));
});

If someone can test and confirm, will be nice.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Absolute and Relative Paths
First let's take a simple structure. By prefixing the first slash (/) in the path with a single (.)
Read more >
Paths explained: Absolute, relative, UNC, and URL—Help
A relative path refers to a location that is relative to a current directory. Relative paths make use of two special symbols, a...
Read more >
Angular 5 fix relative path for Assets/ folder - Stack Overflow
So I went from http://localhost:7777/service1/upload to http://localhost:7777/test/service1/upload . Now I am having an other unfixed issue with ...
Read more >
Relative and absolute paths, in the file system and on the web ...
The simplest example of relative path is just a file name, like index.html . So one should be careful with relative paths. If...
Read more >
What are the differences between absolute and relative paths?
Relative paths use the same principle. Suppose you're in /var/log/foo and you want to view a file in /var/log/bar .
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found