webpack-merge-and-include-globally icon indicating copy to clipboard operation
webpack-merge-and-include-globally copied to clipboard

Get filename in transform callback

Open ayush000 opened this issue 4 years ago • 0 comments

Is it possible to get file path of the input file being transformed inside transform callback? For my use case, I need to pass the path to babel's transformSync method.

new MergeIntoSingleFilePlugin({
  files: {
   "output.js": ["inputFile1", "inputFile2", "inputFile3"]
  },
  transform: {
    // Filepath is currently not passed to transform callback. This is just an example to demonstrate use case
    "output.js": (code, filePath) => {
      babel.transformSync(code, {filename: filePath});
    }
  }
})

For now, it is working for me just by specifying some random filePath, since babel is just using filePath for matching it against overrides. But I was wondering if others might have a similar usecase.

ayush000 avatar Jan 15 '21 09:01 ayush000