如何使用 Closure Controller 获取地图文件中的相对路径而不是完整路径? `
How to get relative path, not full path in map files with Closure Controller? `
我正在使用 Google Closure Compiler 来缩小我的 JS 脚本:https://developers.google.com/closure/compiler/docs/gettingstarted_app?hl=en
我使用的命令是:
java -jar /home/user/compiler/compiler.jar --js $File::Find::name --create_source_map $File::Find::name.map --source_map_format=V3 --compilation_level=WHITESPACE_ONLY --js_output_file $minified --charset=Windows-1251 --output_wrapper '%output%\n//# sourceMappingURL=output.js.map'
很好,除了一件事 - .js.map 文件具有文件的 FULL 路径,而不是相对的:
"version":3,
"file":"/home/user/public_html/new_design/common37.min.js",
"lineCount":375,
....
我假设我可以在 compiler.jar 脚本的调用中更改它?否则,我想我将不得不在我的脚本中添加更多代码(如果可能的话,这不是我想做的事情"out of the box")
编辑: 我在我的 Perl 脚本中做了一些肮脏的修改:
# now open the map file one, and edit it to remove the full path.. needs to be relative
my $contents = File::Slurp::read_file("/home/user/public_html/$tmp.map");
$contents =~ s|/home/user/public_html||g;
File::Slurp::write_file("/home/user/public_html/$tmp.map",$contents);
正确地去掉了路径信息。我更喜欢 .map 文件中是否有使用相对 URL 的选项(与它当前放入的完整路径相比)
谢谢!
使用 --source_map_location_mapping
标志指定 sourcemap 位置转换。该标志需要一个格式为:
的值
--source_map_location_mapping=/filesystem/src/root|relative/source/root
我正在使用 Google Closure Compiler 来缩小我的 JS 脚本:https://developers.google.com/closure/compiler/docs/gettingstarted_app?hl=en
我使用的命令是:
java -jar /home/user/compiler/compiler.jar --js $File::Find::name --create_source_map $File::Find::name.map --source_map_format=V3 --compilation_level=WHITESPACE_ONLY --js_output_file $minified --charset=Windows-1251 --output_wrapper '%output%\n//# sourceMappingURL=output.js.map'
很好,除了一件事 - .js.map 文件具有文件的 FULL 路径,而不是相对的:
"version":3,
"file":"/home/user/public_html/new_design/common37.min.js",
"lineCount":375,
....
我假设我可以在 compiler.jar 脚本的调用中更改它?否则,我想我将不得不在我的脚本中添加更多代码(如果可能的话,这不是我想做的事情"out of the box")
编辑: 我在我的 Perl 脚本中做了一些肮脏的修改:
# now open the map file one, and edit it to remove the full path.. needs to be relative
my $contents = File::Slurp::read_file("/home/user/public_html/$tmp.map");
$contents =~ s|/home/user/public_html||g;
File::Slurp::write_file("/home/user/public_html/$tmp.map",$contents);
正确地去掉了路径信息。我更喜欢 .map 文件中是否有使用相对 URL 的选项(与它当前放入的完整路径相比)
谢谢!
使用 --source_map_location_mapping
标志指定 sourcemap 位置转换。该标志需要一个格式为:
--source_map_location_mapping=/filesystem/src/root|relative/source/root