gulp-inject: Can't remove beginning of injected path using 'IgnorePath'
I’m trying to have gulp-inject, inject a bunch of JS files in my app.
My folder structure looks like this
gulpfile.js
app/
scripts/
index.html
The file comments that get injected look like this.
<script src="/app/scripts/app.js"></script>
However I need to remove the /app/ so the index.html file loads the .js files properly.
I’ve tried adding this {ignorePath: 'app'} but it doesn’t seem to remove it from the inject comments.
Any ideas?
About this issue
- Original URL
- State: closed
- Created 10 years ago
- Comments: 35 (5 by maintainers)
This works for me:
oh, and you will also need to use inject’s {addRootSlash: false}.
hi, came across a similar problem. Figured out it was a typo (two) in the docs:
this block is missing a
)so if you copy from the examples, gulp will build without showing any error:should be:
here is a working example:
johannesjo 👍
And this issue … Let me just say I’ve had an amazing time with this project, until I stumbled across this problem. Definitely the Achilles Heel so far.
Docs don’t really talk about it. Solutions are many with mixed results. Meanwhile so many projects have something like a src or app folder, and a gulp file on the root, causing this issue.
And after a few hours here is my working code :
producing
Sorry, that’s coffee script. I’ve added print(), but it’s not really giving me anything useful…here it is in JS this time…
This works for me:
var paths = { html: [‘doc/_src//.html’, '!doc/_src/_partials/.html’], scripts: 'doc/js//.js’, styles: 'doc/styles/css/.css’, out: ‘doc/’ };
gulp.task(‘inject’, function () { gulp.src(paths.html) .pipe(inject(gulp.src([paths.styles], {read: false}), // Options { ignorePath: ‘doc’, addRootSlash: false } )) .pipe(gulp.dest(paths.out)); });
ignorePath: 'x'and…addRootSlash: falsesolved my issues with this, thanksI tried your code above. Nothing is printed out. However, if i remove the
cwdcommand, it works…You really should use a tool to convert your coffee to js, here, I can tell you did it by hand because there is one closing paranthesis too many. or just paste your coffee script and I’ll either understand it or convert it. Try this: