Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Get filename in transform callback #58

Open
ayush000 opened this issue Jan 15, 2021 · 0 comments
Open

Get filename in transform callback #58

ayush000 opened this issue Jan 15, 2021 · 0 comments

Comments

@ayush000
Copy link

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant