原因と解決方法がわからないという問題があります。gulp 注入には理由がなく、警告やエラーがなく、終了するのに非常に長い時間がかかります。その後、正常に完了します (タスクを完了するのに約 70 分かかったことがわかります!、時には 80 ~ 120 分かかりました):
25-Jan-2016 10:11:54 [10:11:54] Using gulpfile C:\[PATH]\gulpfile.js
25-Jan-2016 10:11:54 [10:11:54] Starting 'scripts'...
25-Jan-2016 10:11:54 [10:11:54] Starting 'styles'...
25-Jan-2016 10:11:55 [10:11:55] Starting 'partials'...
25-Jan-2016 10:11:55 [10:11:55] Starting 'fonts'...
25-Jan-2016 10:11:56 [10:11:56] Starting 'other'...
25-Jan-2016 10:11:58 [10:11:58] gulp-inject 127 files into index.scss.
25-Jan-2016 10:11:59 [10:11:59] Finished 'fonts' after 3.28 s
25-Jan-2016 10:11:59 [10:11:59] all files 447.2 kB
25-Jan-2016 10:11:59 [10:11:59] Finished 'scripts' after 5.27 s
25-Jan-2016 10:12:01 [10:12:01] Finished 'partials' after 5.82 s
25-Jan-2016 10:12:42 [10:12:42] Finished 'styles' after 48 s
25-Jan-2016 10:12:42 [10:12:42] Starting 'inject'...
25-Jan-2016 10:12:42 [10:12:42] gulp-inject 1 files into index.html.
25-Jan-2016 10:12:44 [10:12:44] gulp-inject 210 files into index.html.
25-Jan-2016 10:12:44 [10:12:44] Finished 'inject' after 2.29 s
25-Jan-2016 10:12:44 [10:12:44] Starting 'html'...
25-Jan-2016 10:12:51 [10:12:51] gulp-inject 1 files into index.html.
25-Jan-2016 11:20:00 [11:20:00] dist\ maps\styles\app-04813dcfd7.css.map 319.71 kB
25-Jan-2016 11:20:02 [11:20:02] dist\ maps\styles\vendor-67763da458.css.map 27.75 kB
25-Jan-2016 11:23:19 [11:23:19] dist\ maps\scripts\vendor-334967a88b.js.map 11.95 MB
25-Jan-2016 11:23:28 [11:23:28] dist\ maps\scripts\app-5e1af1a1bd.js.map 1.23 MB
25-Jan-2016 11:23:28 [11:23:28] dist\ styles\app-04813dcfd7.css 750.67 kB
25-Jan-2016 11:23:28 [11:23:28] dist\ styles\vendor-67763da458.css 69.68 kB
25-Jan-2016 11:23:28 [11:23:28] Finished 'other' after 1.19 h
25-Jan-2016 11:23:29 [11:23:29] dist\ scripts\vendor-334967a88b.js 2.89 MB
25-Jan-2016 11:23:30 [11:23:30] dist\ scripts\app-5e1af1a1bd.js 714.37 kB
25-Jan-2016 11:23:30 [11:23:30] dist\ index.html 1.44 kB
25-Jan-2016 11:23:30 [11:23:30] dist\ all files 17.96 MB
25-Jan-2016 11:23:30 [11:23:30] Finished 'html' after 1.18 h
25-Jan-2016 11:23:30 [11:23:30] Starting 'build'...
25-Jan-2016 11:23:30 [11:23:30] Finished 'build' after 21 μs
25-Jan-2016 11:23:30 Finished task 'Gulp build' with result: Success
コードを提供します。この問題のトラブルシューティング方法や解決策を見つけたいと思います。
挿入タスク:
var path = require('path');
var gulp = require('gulp');
var conf = require('./conf');
var $ = require('gulp-load-plugins')();
var wiredep = require('wiredep').stream;
var _ = require('lodash');
var browserSync = require('browser-sync');
gulp.task('inject-reload', ['inject'], function ()
{
browserSync.reload();
});
gulp.task('inject', ['scripts', 'styles'], function ()
{
var injectStyles = gulp.src([
path.join(conf.paths.tmp, '/serve/app/**/*.css'),
path.join('!' + conf.paths.tmp, '/serve/app/vendor.css')
], {read: false});
var injectScripts = gulp.src([
path.join(conf.paths.src, '/app/**/*.module.js'),
path.join(conf.paths.src, '/app/**/*.js'),
path.join('!' + conf.paths.src, '/app/**/*.spec.js'),
path.join('!' + conf.paths.src, '/app/**/*.mock.js'),
])
.pipe($.angularFilesort()).on('error', conf.errorHandler('AngularFilesort'));
var injectOptions = {
ignorePath : [conf.paths.src, path.join(conf.paths.tmp, '/serve')],
addRootSlash: false
};
return gulp.src(path.join(conf.paths.src, '/*.html'))
.pipe($.inject(injectStyles, injectOptions))
.pipe($.inject(injectScripts, injectOptions))
.pipe(wiredep(_.extend({}, conf.wiredep)))
.pipe(gulp.dest(path.join(conf.paths.tmp, '/serve')));
});
必要な場合は conf ファイル:
var gutil = require('gulp-util');
/**
* The main paths of your project handle these with care
*/
exports.paths = {
src : 'src',
dist: 'dist',
tmp : '.tmp',
e2e : 'e2e'
};
/**
* Wiredep is the lib which inject bower dependencies in your project
* Mainly used to inject script tags in the index.html but also used
* to inject css preprocessor deps and js files in karma
*/
exports.wiredep = {
directory: 'bower_components'
};
/**
* Common implementation for an error handler of a Gulp plugin
*/
exports.errorHandler = function (title)
{
'use strict';
return function (err)
{
gutil.log(gutil.colors.red('[' + title + ']'), err.toString());
this.emit('end');
};
};