django-webpack / webpack-bundle-tracker

Spits out some stats about webpack compilation process to a file
MIT License
268 stars 107 forks source link

Setting "path" option no longer works #108

Closed bennettrogers closed 1 year ago

bennettrogers commented 2 years ago

It seems that setting the path option in the BundleTracker options no longer has an effect. I think the issue was introduced in this commit. Regardless of what the path option is set to, the stats file is rooted in the cwd.

It's possible to work around the issue by specifying the full file path in the filename option.

fjsj commented 2 years ago

Hi @bennettrogers, this was changed on https://github.com/django-webpack/webpack-bundle-tracker/pull/91

We still have the outputChunkDir variable and we use it: https://github.com/django-webpack/webpack-bundle-tracker/blob/8a517eea7b30e8ac47ce5a7d2d93eca356fe8e52/lib/index.js#L71

but only if the filename is a relative path: https://github.com/django-webpack/webpack-bundle-tracker/blob/8a517eea7b30e8ac47ce5a7d2d93eca356fe8e52/lib/index.js#L161-L163

Are you passing a relative filename path? Or does it have a leading /?

dannyshaw commented 2 years ago

@fjsj There might be some confusion here, the webpack-stats.json file seems to not be respecting the path option provided in options and is now just writing the stats file in the pwd. Your response seems to be in relation to publicPath that's written for each chunk. This is a bug with the path to webpack-stats.json

I can confirm I've worked around the bug by using an absolute filename. If this is intentional then perhaps the docs need updating?

Broken:

new BundleTracker({
  path: OUTPUT_DIRECTORY,
  filename: 'webpack-stats.json'
})

Workaround:

new BundleTracker({
  filename: path.join(
    OUTPUT_DIRECTORY,
    'webpack-stats.json'
})
vasili4396 commented 1 year ago

same here, upgraded from 0.4.2 to 1.8.0

not a big deal, as a workaround mentioned above is perfectly fine, but d.ts tells me, that I should be able to use this (broken) option, which is confusing

fjsj commented 1 year ago

So I think the issue is on typings.d.ts Thanks for reporting @vasili4396 If you can/want open a PR solving this, please feel free.