Skip to content

webpack 的源码映射功能

中文文档


什么是源码映射?

  1. 使用 webpack 打包, 生成的文件不止我们自己写的代码, 还有一些其他的代码, 如果程序报错, 此时根本无法知道是哪行代码, 甚至那个文件报错...

验证步骤

  1. 新建一个 js 文件, 就输入以下内容, 让它报错, 然后在浏览器中看效果就能知道
alert(abc);

推荐设置

  • 开发环境: cheap-module-eval-source-map
js
module.exports = {
  mode: "development",
  devtool: "cheap-module-eval-source-map",
};
  • 生产环境: cheap-module-source-map
js
module.exports = {
  mode: "production",
  devtool: "cheap-module-source-map",
};

Released under the MIT License.

Layout Switch

Adjust the layout style of VitePress to adapt to different reading needs and screens.

Expand all
The sidebar and content area occupy the entire width of the screen.
Expand sidebar with adjustable values
Expand sidebar width and add a new slider for user to choose and customize their desired width of the maximum width of sidebar can go, but the content area width will remain the same.
Expand all with adjustable values
Expand sidebar width and add a new slider for user to choose and customize their desired width of the maximum width of sidebar can go, but the content area width will remain the same.
Original width
The original layout width of VitePress

Page Layout Max Width

Adjust the exact value of the page width of VitePress layout to adapt to different reading needs and screens.

Adjust the maximum width of the page layout
A ranged slider for user to choose and customize their desired width of the maximum width of the page layout can go.

Content Layout Max Width

Adjust the exact value of the document content width of VitePress layout to adapt to different reading needs and screens.

Adjust the maximum width of the content layout
A ranged slider for user to choose and customize their desired width of the maximum width of the content layout can go.

Spotlight

Highlight the line where the mouse is currently hovering in the content to optimize for users who may have reading and focusing difficulties.

ONOn
Turn on Spotlight.
OFFOff
Turn off Spotlight.