Гулп-накопительные исходные карты внешних файлов - PullRequest
0 голосов
/ 08 декабря 2018

Я использую плагин gulp rollup для исходных карт , я могу видеть свои исходные карты в devtools браузера, но мне нужно иметь возможность создавать внешние исходные карты также для каждого файла javascript.

Результат такой: enter image description here

Это мой код, и я не вижу никаких файлов .map в моих файлах:

gulp.task('js', () => rollup({
  input: jsEntryFile, 
  sourcemap: true,
  plugins: [
    builtins(),
    nodeResolve({
      browser: true
    }),
    babel({
      exclude: 'node_modules/**'
    }),
    commonJs(),
    globals(),
    uglify(),
    sourcemaps(),
    json()
  ],
  format: 'umd'
})
  .on('error', function (err) {
    console.error(err)
    this.emit('end')
  })
  .pipe(source(jsOutputFileName))
  .pipe(gulp.dest(jsOutputDir))
)

Решение:

gulp.task('js', (entry, outputFileName, jsOutputDir) => rollup({
  input: entry,
    plugins: [
      builtins(),
      nodeResolve({
        browser: true
      }),
      babel({
        exclude: 'node_modules/**'
      }),
      commonJs(),
      globals(),
      uglify(),
      json()
    ],
    format: 'umd'
  })
  .on('error', function (err) {
    console.error(err)
    this.emit('end')
  })
  // point to the entry file.
  .pipe(source(outputFileName))

  // buffer the output. most gulp plugins, including gulp-sourcemaps, don't support streams.
  .pipe(buffer())

  // tell gulp-sourcemaps to load the inline sourcemap produced by rollup-stream.
  .pipe(gulpSourceMaps.init({loadMaps: true}))

  // write the sourcemap alongside the output file.
  .pipe(gulpSourceMaps.write('.'))

  // Output file diretory
  .pipe(gulp.dest(jsOutputDir))

)
...