javascript - gulp-load-plugins.sourcemaps.init() TypeError: Cannot read property 'init' of undefined -
i'm trying adapt gulp file purposes , i'm running issues. care 1 task:
gulp.task('js:browser', function () { return mergestream.apply(null, object.keys(jsbundles).map(function(key) { return bundle(jsbundles[key], key); }) ); });
it using browserify condense bundle usable single file. uses these 2 methods , object:
function createbundle(src) { //if source not array, make 1 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 happen .on('error', plugins.util.log.bind(plugins.util, 'browserify error')) .pipe(source(outputfile)) // optional, remove if don't need buffer file contents .pipe(buffer()) // optional, remove if dont want sourcemaps .pipe(plugins.sourcemaps.init({loadmaps: true})) // loads map browserify file // add transformation tasks 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']) };
when run gulp task js:bower following error coming the .pipe(plugins.sourcemaps.init({loadmaps: true}))
expression:
typeerror: cannot read property 'init' of undefined
i know lines optional , can comment them out, want them. when run code in example file works properly, when run in gulp file gives me error. suggestions on might missing? thanks!
gulp-load-plugins
analyzes contents of package.json
file find out gulp plugins have installed. make sure gulp-sourcemaps
among "devdependencies"
defined there. if not run
npm install --save-dev gulp-sourcemaps
there's small chance problem related lazy loading sourcemaps plugin. if above doesn't try requiring gulp-load-plugins
this:
var plugins = require('gulp-load-plugins')({lazy:false});
Comments
Post a Comment