inject java script files to index.html page in particular order but its injecting in different way?
SIMHACHALAM1001 opened this issue · 2 comments
so my code is :
gulp.task('js', function () {
gulp.src("client/js/*.js")
.pipe(order(['client/js/angular.min.js',
'client/js/jquery-1.10.2.min.js',
'client/js/ngStorage.min.js',
'client/js/angular-scroll.min.js',
'client/js/angular-material.min.js',
'client/js/angular-animate.min.js',
'client/js/angular-aria.min.js',
'client/js/angular-messages.min.js',
'client/js/ui-bootstrap-tpls-2.0.1.js',
'client/js/ng-youtube-embed.min.js',
'client/js/bootstrap.min.js',
'client/js/slick.min.js',
'client/js/headroom.js',
'client/js/angular.headroom.js',
'client/js/angular-route.min.js',
'client/js/angular-slick.min.js',
'client/js/slick.min.js',
'client/js/angular-cookies.min.js',
'client/js/ngInfiniteScroll.js',
'client/js/angular-spinkit.min.js',
'client/js/angular-scroll.min.js',
'client/js/lodash.js'
]))
.pipe(gulp.dest('build/js/'));
});
gulp.task('index',function () {
return gulp.src('client/index.html')
.pipe(inject(gulp.src(['build/js/.js','build/css/.css'], {read: false}), {ignorePath: 'build'}))
.pipe(gulp.dest('build'))
.pipe(livereload());
})
gulp.task('default', ['js','css', 'index','browser-sync','watch']);
i used inject order but not injecting in that order ,so any modifications please,and i am not using any bower.
so how can i inject that pipe order files injection .pipe(order(['',''...])
any help please
Hey bud
I just used this and I think your problem is not ordering the stream that you're putting into inject. So where you have:
.pipe(inject(gulp.src(['build/js/.js','build/css/.css'], {read: false}), {ignorePath: 'build'}))
add the order statement to that dest stream like this:
.pipe(inject(gulp.src(['build/js/.js','build/css/.css'], {read: false}), {ignorePath: 'build'}).order([...]))
Hope it helps :)
@claudemuller Thanks for your advise, but it is not working for me:
'inject' errored after 17 ms
[12:02:56] TypeError: inject(...).order is not a function
this works for me by using gulp-order plugin:
var order = require("gulp-order");
// insert task
gulp.task('inject', function () {
gulp.src(paths.index)
.pipe(plumber())
// inject bower files
.pipe(inject(gulp.src(paths.injectPath.bowerFiles, {read: false}).pipe(order(["ionic.bundle.min.js"])), {name:'bower', relative: true}))
// inject your own css
.pipe(inject(gulp.src(paths.injectPath.appCss, {read: false}), {starttag: '<!-- inject:appCss:{{ext}} -->', relative: true}))
// inject your own js
.pipe(inject(gulp.src(paths.injectPath.appJs, {read: false}), {starttag: '<!-- inject:appJs:{{ext}} -->', relative: true}))
.pipe(gulp.dest(paths.src))
});
or as simple as below:
inject(gulp.src(paths.injectPath.bowerFiles, {read: false}).pipe(order(["your-js1.js", your-js2.js", ...])
It works for me, hope it helps!