Ich versuche, eine Schluckdatei an meine Zwecke anzupassen, und ich stoße auf Probleme. Ich interessiere mich nur für eine Aufgabe:gulp-load-plugins.sourcemaps.init() TypeError: Kann Eigenschaft 'init' von undefined nicht lesen
Es verwendet browserify, um mein Bündel in eine verwendbare einzelne Datei zu verdichten. Es verwendet diese beiden Methoden und dieses Objekt:
function createBundle(src) {
//if the source is not an array, make it one
if (!src.push) {
src = [src];
}
var customOpts = {
entries: src,
debug: true
};
var opts = assign({}, watchify.args, customOpts);
var b = watchify(browserify(opts));
b.transform(babelify.configure({
stage: 1
}));
b.transform(hbsfy);
b.on('log', plugins.util.log);
return b;
}
function bundle(b, outputPath) {
var splitPath = outputPath.split('/');
var outputFile = splitPath[splitPath.length - 1];
var outputDir = splitPath.slice(0, -1).join('/');
console.log(outputFile);
console.log(plugins);
return b.bundle()
// log errors if they happen
.on('error', plugins.util.log.bind(plugins.util, 'Browserify Error'))
.pipe(source(outputFile))
// optional, remove if you don't need to buffer file contents
.pipe(buffer())
// optional, remove if you dont want sourcemaps
.pipe(plugins.sourcemaps.init({loadMaps: true})) // loads map from browserify file
// Add transformation tasks to the pipeline here.
.pipe(plugins.sourcemaps.write('./')) // writes .map file
.pipe(gulp.dest('build/public/' + outputDir));
}
var jsBundles = {
'js/polyfills/promise.js': createBundle('./public/js/polyfills/promise.js'),
'js/polyfills/url.js': createBundle('./public/js/polyfills/url.js'),
'js/settings.js': createBundle('./public/js/settings/index.js'),
'js/main.js': createBundle('./public/js/main/index.js'),
'js/remote-executor.js': createBundle('./public/js/remote-executor/index.js'),
'js/idb-test.js': createBundle('./public/js/idb-test/index.js'),
'sw.js': createBundle(['./public/js/sw/index.js', './public/js/sw/preroll/index.js'])
};
Wenn ich die schluck Aufgabe js laufen: Bower bekomme ich folgende Fehler aus dem der .pipe(plugins.sourcemaps.init({loadMaps: true}))
Ausdruck kommt:
TypeError: Cannot read property 'init' of undefined
Ich weiß, dass die Linien optional und ich kann sie einfach kommentieren, aber ich will sie. Wenn ich den Code in der Beispieldatei ausführe funktioniert es richtig, wenn ich es in meiner Schluckdatei ausführe, gibt es mir den Fehler. Irgendwelche Vorschläge, was ich vermisse? Vielen Dank!