Skip to content

Commit 15e47b0

Browse files
authored
Debugging: generate source map (#65)
Source maps are useful to debug minified code. It allows developer to request "the original source code" when using Developer Tools on Firefox (or Chrome) and be able to debug it in production. Since our script is open-source and its repository is public, I don't think there is any security concern we should care about here (at this point, at least). However, regular users will only get the minified version of it. Note this option adds an extra ~1s to `npm run build` and `npm run dev`, but I think that's not a problem for our use case. ![Screenshot_2023-05-01_10-31-49](https://user-images.githubusercontent.com/244656/235497668-92e47971-9c76-425e-9dd7-6ccc8d8e9032.png) Reference: https://webpack.js.org/configuration/devtool/ Reference: https://webpack.js.org/plugins/terser-webpack-plugin/#terseroptions
1 parent 2ec01e9 commit 15e47b0

File tree

3 files changed

+13
-7
lines changed

3 files changed

+13
-7
lines changed

dist/readthedocs-client.js

Lines changed: 8 additions & 7 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/readthedocs-client.js.map

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

webpack.config.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,9 @@ module.exports = (env, argv) => {
4141
new TerserPlugin({
4242
// Avoids creating a `.LICENSE.txt` file
4343
extractComments: false,
44+
terserOptions: {
45+
sourceMap: true,
46+
},
4447
}),
4548
],
4649
},
@@ -76,6 +79,7 @@ module.exports = (env, argv) => {
7679
],
7780

7881
// Development options
82+
devtool: "source-map",
7983
watchOptions: {
8084
aggregateTimeout: 1000,
8185
ignored: ["/node_modules/", "**/node_modules/"],

0 commit comments

Comments
 (0)