Reputation: 725
I am using bower & npm as package manager to handle dependencies. now the bower is showing
npm WARN deprecated [email protected]: ...psst!
Your project can stop working at any moment because its dependencies can change. Prevent this by migrating to Yarn:
https://bower.io/blog/2017/how-to-migrate-away-from-bower/
So i have integrated yarn
using bower-away
. Now all the bower dependencies are moved into my package.json as like below
"@bower_components/angular": "angular/bower-angular#~1.6.4",
"@bower_components/jquery": "jquery/jquery-dist#>= 1.9.1"
I used wiredep
to inject all the dependency libraries into index.html. It will automatically handle bower dependencies.
Now i have removed bower
completely so this won't work.
Is there any other method to move dependencies into index.html. currently I am using gulp inject
method to inject all the files like as below .pipe(inject(gulp.src(["./src/*.js", "./src/*.css"], {read: false}))
but it's not handling for all packages. because path is completely different.
For Ex: jquery and angular folder like as below
can anyone suggest is there any other method to achieve this.
Upvotes: 2
Views: 1641
Reputation: 328
you still able to fix it using gulp inject
:
gulp.task('injectfiles', function () {
var appJS= ["./src/*.js"];// pattern to match your files
var libJS= [
'(path where jquery exist)/jquery.js',
'(path where angular exist)/angular.js'
];
var jsOrder= [
'**/jquery.js',
'**/angular.js',
'(rest lib js)'
'**/app.module.js',
'**/*.module.js',
'**/*.constants.js',
'**/*.value.js',
'**/*.config.js',
'**/*.route.js',
'**/*.filter.js',
'**/*.service.js',
'**/*.controller.js',
'**/*.directive.js',
'**/*.js'
];
var src = [].concat(libJS,appJS)
return gulp
.src('index path')
.pipe(inject(src, '', jsOrder))
.pipe(gulp.dest('dest path'))
})
function inject(src, label, order) {
// var options = { read: false };
var options = {}
if (label) {
options.name = 'inject:' + label
}
return $.inject(orderSrc(src, order), options)
}
function orderSrc(src, order) {
// order = order || ['**/*'];
return gulp
.src(src)
.pipe($.if(order, $.order(order)))
}
Upvotes: 1