shellscape / webpack-manifest-plugin

webpack plugin for generating asset manifests
MIT License
1.44k stars 184 forks source link

an option to create the manifest json to specified directory #33

Closed tomwang1013 closed 7 years ago

tomwang1013 commented 7 years ago

Now the manifest.json is created under output.path which is set in webpack.config.js. But i want it to be in other directory.

btamas commented 7 years ago

It's working for me if I define filname as a path of output.

...
new ManifestPlugin({
    fileName : path.join(__dirname, '..', 'rev-manifest.json'),
    basePath : '/js/',
  })
...
tomwang1013 commented 7 years ago

@btamas this didn't work for me. Say output.path is public/assets, the absolute path of my application is /home/wangxiantong/learning/mysite, the result of your solution for me is:

default

which is terribly incorrect. Does basePath matter? i didn't set basePath

dcurletti commented 7 years ago

I second this problem. I too am having issues with wanting to write to a specific directory.

arthens commented 7 years ago

Using a relative path as file name worked for me

new ManifestPlugin({
     fileName : '../../manifest.json',
}),

but it feels very hacky and I agree that it should be its own configuration option.

zuzusik commented 7 years ago

btw, this got broken somewhere after 1.0.0 with version lower than 1.0.0 we had fileName: './rev-manifest-webpack.json', and the file was placed to the folder in which webpack config is placed where with the latest version it gets placed in the dist folder - where we do the webpack output

this is not good - I don't want my dist folder to have this file - it is not needed in dist

mastilver commented 7 years ago

I agree with you, I think manifest.json path should be relative to cwd or context

That causing the issue, is this: https://github.com/danethurber/webpack-manifest-plugin/blob/master/lib/plugin.js#L97-L104

I think it should be dropped, and the plugin should write to disk by himself, no rely on webpack to do it

I also believe that it will fix: #21

Thoughts?

mastilver commented 7 years ago

@btamas 's solution should work for now

for v2, it will use cwd as base directory

zuzusik commented 7 years ago

That causing the issue, is this: https://github.com/danethurber/webpack-manifest-plugin/blob/master/lib/plugin.js#L97-L104 I think it should be dropped, and the plugin should write to disk by himself, no rely on webpack to do it

@mastilver if we just drop these lines you reference we bring back other bugs, look at the description of the PR where those lines were added: https://github.com/danethurber/webpack-manifest-plugin/pull/6

So I guess it should be done with own configuration option

mastilver commented 7 years ago

@zuzusik Can you check #56 for me, does it make sense?

zuzusik commented 7 years ago

@mastilver it looks like https://github.com/danethurber/webpack-manifest-plugin/pull/56 still doesn't give an ability to write file somewhere else rather than Webapck's output.path without hacky approach described in https://github.com/danethurber/webpack-manifest-plugin/issues/33#issuecomment-302951171

So maybe it fixes #21 but looks like it still doesn't fix this particular issue

mastilver commented 7 years ago

I know, I doing things step by step

56 will land on a release for v1 while for v2 we will change the way we handle fileName

mastilver commented 7 years ago

56 is doing: I think it should be dropped, and the plugin should write to disk by himself, no rely on webpack to do it so it's a step forward fixing this issue :)

mastilver commented 7 years ago

The best way to do it right now is to do it that way: https://github.com/danethurber/webpack-manifest-plugin/blob/master/spec/plugin.spec.js#L479

I will make sure it even works in the future

mastilver commented 7 years ago

I'm closing this as the solution to this is to use an absolute path: fileName: path.join(__dirname, 'manifest.json')