injecting node_modules files add index.js content as main index.html code again
- Dominant language
- JavaScript
- Stars
- 807
- Forks
- 90
- PR merge metrics
- No merged PRs in 30d
Description
mac os 10.13.1
gulp-inject v 4.3.0
```
'use strict';
var path = require('path');
var gulp = require('gulp');
var conf = require('./conf');
var $ = require('gulp-load-plugins')();
var es = require('event-stream');
var mainNPMFiles = require('npmfiles');
// var wiredep = require('wiredep').stream;
// var _ = require('lodash');
gulp.task('inject-reload', ['inject'], function() {
$.connect.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')
]);
var injectScripts = gulp.src([
path.join(conf.paths.src, '/app/**/*.js'),
path.join('!' + conf.paths.src, '/app/**/*.spec.js'),
path.join('!' + conf.paths.src, '/app/**/*.mock.js')
])
// support for es6
.pipe($.babel({"presets": [ ["env", { modules: false}] ], compact: false}))
.pipe($.angularFilesort()).on('error', conf.errorHandler('AngularFilesort'));
// for 3rd party js files
var injectOptions = {
ignorePath: [conf.paths.src, path.join(conf.paths.tmp, '/serve')],
addRootSlash: false
};
var injectVendor = gulp.src([path.join(conf.paths.src, '/libs/**/*.js')], {
read: false
});
var vendorOptions = {
starttag: '',
ignorePath: [conf.paths.src, path.join(conf.paths.tmp, '/serve')],
addRootSlash: false
};
var npmVendors = gulp.src(mainNPMFiles( {nodeModulesPath: '../node_modules/'} ));
var npmOptions = {
relative: true,
starttag: '',
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($.inject(injectVendor, vendorOptions))
.pipe($.inject(npmVendors, npmOptions))
.pipe(gulp.dest(path.join(conf.paths.tmp, '/serve')));
});
```
###.tmp/index.html
```
...
```
all these node_modules/packages/index.js has the index.html code when checking in the console.
why so?
also tried without *realtive* options
see the screenshot

Contributor guide
No contributing guide indexed for this repository
Research direction
Start with the gulp inject task shown in the report, especially the npmVendors stream created from npmfiles and the .tmp/index.html output. Reproduce the injection with the listed node_modules packages and inspect why their generated script paths point to index.js content. Done means the injected npm entries reference the intended package JavaScript files without duplicating index.html content.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript, node.js
- Domain
- build-system, tooling
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 35/100