Witam,
Od 2 godzini próbuje dodać do mojego gulpbuilda taska który wyciągnie linijki kodu (skrypt) z danego pliku i je do innego pliku.
Udało mi się znaleźć coś takiego:
gulp.task('inject', function(){ gulp.src('src/main/**/*.html') // This is the source file that will have content injected into .pipe(inject(gulp.src(['src/main/content/build/google-analytics.js']), { // This is the file that has the content that will be injected into index.html starttag: '<!-- GOOGLE_ANALYTIC -->', // Here we tell the location in which we want the injection to occur transform: function (filePath, file) { return file.contents.toString('utf8') // Return file contents as string } })) .pipe(gulp.dest('dist')); // This is the destination of the final product }); // Tasks to run when gulp dist is run on the command line gulp.task('dist', ['inject']);
<!-- GOOGLE_ANALYTIC --> <!-- endinject -->
ale dalej nie działa :l