我可以将 webpack 源映射和源代码文件放在不同的文件夹中吗?
Can I place webpack source maps and source code files in seprate folders?
我阅读了这个问题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并进行了测试,但再次失败。
您可以像这样使用 output.sourceMapFilename
:
output: {
filename: "bundles/[name].[chunkhash].min.js",
sourceMapFilename: 'maps/[name].[chunkhash].map.js'
},
然后仅从 bundles
文件夹提供服务。
正如 Ivan 所写,解决方案是使用 output.sourceMapFilename
但是,webpack doc 推荐的解决方案是仅使用 [file]
占位符(默认值为 [file].map
)。
那么最好定义如下值:
output: {
filename: 'js/[name]-[chunkhash].js',
sourceMapFilename: 'sourceMap/[file].map'
},
然后您将保留结构,它也适用于 css sourceMaps
我阅读了这个问题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并进行了测试,但再次失败。
您可以像这样使用 output.sourceMapFilename
:
output: {
filename: "bundles/[name].[chunkhash].min.js",
sourceMapFilename: 'maps/[name].[chunkhash].map.js'
},
然后仅从 bundles
文件夹提供服务。
正如 Ivan 所写,解决方案是使用 output.sourceMapFilename
但是,webpack doc 推荐的解决方案是仅使用 [file]
占位符(默认值为 [file].map
)。
那么最好定义如下值:
output: {
filename: 'js/[name]-[chunkhash].js',
sourceMapFilename: 'sourceMap/[file].map'
},
然后您将保留结构,它也适用于 css sourceMaps