0

this is my project

 - Project root

 |-  build
     |-css
     |-js
     |-index.html

 |-  src
     |- css
     |- js
     |-index.html

 |-gulpfile.js

I use gulp and want to inject build/scc and build/js files into src/index.html and place it as build/index.html

Done this :

gulp.task('index', function () {
  var target = gulp.src('src/index.html');
  var sources = gulp.src(['build/js/*.js', 'build/styles/*.css'], { ignorePath: 'build/', addRootSlash: false });
  return target.pipe(inject(sources))
    .pipe(gulp.dest('build'));
});

I need to skip the '/build/' part But still on output of html file shows :

<link rel="stylesheet" href="/build/styles/app.min.css">
<script src="/build/js/app.min.js"></script>
3
  • have you tried "../build/xxx" Dec 19, 2016 at 9:46
  • nope,how you do that? Dec 19, 2016 at 9:55
  • pretty simple just add .. to jump up a folder like this: <link rel="stylesheet" href="../build/styles/app.min.css"> Dec 19, 2016 at 9:56

1 Answer 1

0
- Project root

 |-  build
     |-css
     |-js
     |-index.html

 |-  src
     |- css
     |- js
     |-index.html

 |-gulpfile.js

Now we are in index.html which is in build directory(folder), we need to go a step backward to have access to the src directory, and .. will be the parent directory of the current directory (means build)

then you can use this:

<link rel="stylesheet" href="../build/styles/app.min.css">

Reading more about relative and absolute path will help you to learn more about this

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.