Bower and Gulp changing file paths in distribution -
started learning bower , gulp. have app directory development , dist directory final project live ready go out world.
in app directory have installed chart.js through bower , therefore in folder called bower_components/chart.js.
in index.html file have link chart.js as:
<script type="text/javascript" src="bower_components/chart.js/chart.js"></script>
in distribution want in javascript folder
<script type="text/javascript" src="js/chart.js"></script>
how automate changing location of chart.js file in gulp?
i imagine general requirement considering distribution file structure different development file structure.
you can move files on final destination in build pipeline.
const gulp = require('gulp4'); const path = require('path'); gulp.task('libs', () => gulp .src([ path.join(__dirname, 'bower_components', 'chart.js', 'chart.js'), /* other libraries here */ ]) .pipe(gulp.dest(path.join(__dirname, 'js'))))
simply run libs
task before serve html development, , include in pipeline production builds.
then you'd reference these libraries js
folder in html.
Comments
Post a Comment