How to use gulp to place angular,bootstrap, etc. downloaded by bower under scripts or styles directory

  node.js, question

I use gulp to configure a project under Atom. After downloading angular, bootstrap through bower, I don’t know how to use gulp to introduce bower’s downloaded items into the project, such as script, style directories. It is better to explain the principle for solving. . . . ! ^_^

In the project, gulp is not used to introduce bower components. I am not sure if I have correctly understood what you mean. here I say two usages, assuming bower components are installed according to the default path, i.e.bower_components

First kind

exploitation

Direct reference

<script src="/bower_components/angular/angular.js"></script>
 <script src="/bower_components/xxx/yyy.js"></script>
 <script src="/js/app.js"></script>

Release

Use gulp to compress the referenced script

var gulp   = require('gulp'),
 watch  = require('gulp-watch'),
 concat = require('gulp-concat'),
 uglify = require('gulp-uglify');
 
 gulp.src([
 'bower_components/angular/angular.js',
 'bower_components/xxx/yyy.js',
 'js/app.js'
 ])
 .pipe(concat())
 .pipe(uglify())
 .pipe(gulp.dest('./dist'));

The recommended method is to read html files to find all<script>Tag, then merge the compression, and then modify the html file<script>Can use a file reference similar tothrough2The library of

The second

Gulp is used to merge compressed js files during development.

<script src="/dist/app.bundle.js"></script>

Then gulp writes a watch

var gulp   = require('gulp'),
 watch  = require('gulp-watch'),
 concat = require('gulp-concat'),
 uglify = require('gulp-uglify');
 
 gulp.task('default', function (cb) {
 watch('js/app.js', function () {
 gulp.src([
 'bower_components/angular/angular.js',
 'bower_components/xxx/yyy.js',
 'js/app.js'
 ])
 .pipe(concat())
 .pipe(uglify())
 .pipe(gulp.dest('./dist'))
 .on('end', cb);
 });
 });

Finally, I also use webpack, but it cannot completely replace gulp at present, but webpack is indeed the trend in the future. it is suggested to learn, after all, it is simpler than gulp to solve your current problems.