Can I place webpack source maps and source code files in seprate folders?

我的梦境 提交于 2019-12-05 02:52:29

问题


I read this question source maps files in production - is it safe?. I want to generate source map files in different folders with source code. Is there any way to do this with webpack? I also read this thread Relative SourceMap paths for debugging in WebStorm and tested but failed again.


回答1:


You can use output.sourceMapFilename like so:

output: {
    filename: "bundles/[name].[chunkhash].min.js",
    sourceMapFilename: 'maps/[name].[chunkhash].map.js'
},

and then serve only from the bundles folder.




回答2:


As Ivan wrote, the solution is to use output.sourceMapFilename

However, recommended solution from webpack doc is to only use [file] placeholder (default value is [file].map).

It is then best to define the value as following:

output: {
    filename: 'js/[name]-[chunkhash].js',
    sourceMapFilename: 'sourceMap/[file].map'
},

You will then preserve structure and it will also work for css sourceMaps



来源:https://stackoverflow.com/questions/43052200/can-i-place-webpack-source-maps-and-source-code-files-in-seprate-folders

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!