diff --git a/app/webpack.config.js b/app/webpack.config.js index ffb490e58..5d9983c72 100644 --- a/app/webpack.config.js +++ b/app/webpack.config.js @@ -10,7 +10,7 @@ module.exports = (env, argv) => { return { mode: argv.mode || "development", watch: argv.mode !== "production", - devtool: argv.mode !== "production" ? "eval" : false, + devtool: argv.mode !== "production" ? "cheap-source-map" : false, target: "electron-renderer", output: { publicPath: "auto", @@ -25,9 +25,12 @@ module.exports = (env, argv) => { extensions: [".ts", ".js", ".tpl", ".scss", ".png", ".svg"], }, optimization: { - minimize: true, + minimize: argv.mode === "production", minimizer: [ - new EsbuildPlugin({target: "es2021"}), + new EsbuildPlugin({ + target: "es2021", + sourcemap: argv.mode !== "production", + }), ], }, module: { @@ -50,6 +53,7 @@ module.exports = (env, argv) => { loader: "esbuild-loader", options: { target: "es2021", + sourcemap: argv.mode !== "production", }, }, { @@ -69,9 +73,15 @@ module.exports = (env, argv) => { MiniCssExtractPlugin.loader, { loader: "css-loader", // translates CSS into CommonJS + options: { + sourceMap: argv.mode !== "production", + }, }, { loader: "sass-loader", // compiles Sass to CSS + options: { + sourceMap: argv.mode !== "production", + }, }, ], }, diff --git a/app/webpack.desktop.js b/app/webpack.desktop.js index fef265146..2ae81ac38 100644 --- a/app/webpack.desktop.js +++ b/app/webpack.desktop.js @@ -11,7 +11,7 @@ module.exports = (env, argv) => { return { mode: argv.mode || "development", watch: argv.mode !== "production", - devtool: argv.mode !== "production" ? "eval" : false, + devtool: argv.mode !== "production" ? "cheap-source-map" : false, output: { publicPath: "/stage/build/desktop/", filename: "[name].[chunkhash].js", @@ -23,7 +23,10 @@ module.exports = (env, argv) => { optimization: { minimize: true, minimizer: [ - new EsbuildPlugin({target: "es6"}), + new EsbuildPlugin({ + target: "es6", + sourcemap: argv.mode !== "production", + }), ], }, resolve: { @@ -51,6 +54,7 @@ module.exports = (env, argv) => { loader: "esbuild-loader", options: { target: "es6", + sourcemap: argv.mode !== "production", } }, { @@ -72,9 +76,15 @@ module.exports = (env, argv) => { MiniCssExtractPlugin.loader, { loader: "css-loader", // translates CSS into CommonJS + options: { + sourceMap: argv.mode !== "production", + }, }, { loader: "sass-loader", // compiles Sass to CSS + options: { + sourceMap: argv.mode !== "production", + }, }, ], }, diff --git a/app/webpack.export.js b/app/webpack.export.js index 3df070097..dd4bc607d 100644 --- a/app/webpack.export.js +++ b/app/webpack.export.js @@ -10,7 +10,7 @@ module.exports = (env, argv) => { return { mode: argv.mode || "development", watch: argv.mode !== "production", - devtool: argv.mode !== "production" ? "eval" : false, + devtool: argv.mode !== "production" ? "cheap-source-map" : false, output: { publicPath: "auto", filename: "[name].js", @@ -25,7 +25,10 @@ module.exports = (env, argv) => { optimization: { minimize: true, minimizer: [ - new EsbuildPlugin({target: "es6"}), + new EsbuildPlugin({ + target: "es6", + sourcemap: argv.mode !== "production", + }), ], }, resolve: { @@ -44,6 +47,7 @@ module.exports = (env, argv) => { loader: "esbuild-loader", options: { target: "es6", + sourcemap: argv.mode !== "production", } }, { @@ -65,9 +69,15 @@ module.exports = (env, argv) => { MiniCssExtractPlugin.loader, { loader: "css-loader", // translates CSS into CommonJS + options: { + sourceMap: argv.mode !== "production", + }, }, { loader: "sass-loader", // compiles Sass to CSS + options: { + sourceMap: argv.mode !== "production", + }, }, ], }, diff --git a/app/webpack.mobile.js b/app/webpack.mobile.js index 59bb4c8b7..7c6844144 100644 --- a/app/webpack.mobile.js +++ b/app/webpack.mobile.js @@ -11,7 +11,7 @@ module.exports = (env, argv) => { return { mode: argv.mode || "development", watch: argv.mode !== "production", - devtool: argv.mode !== "production" ? "eval" : false, + devtool: argv.mode !== "production" ? "cheap-source-map" : false, output: { // 不能使用 auto,否则 ios 导出图片获取不到 css。 https://github.com/siyuan-note/siyuan/issues/8532 publicPath: "/stage/build/mobile/", @@ -24,7 +24,10 @@ module.exports = (env, argv) => { optimization: { minimize: true, minimizer: [ - new EsbuildPlugin({target: "es6"}), + new EsbuildPlugin({ + target: "es6", + sourcemap: argv.mode !== "production", + }), ], }, resolve: { @@ -52,6 +55,7 @@ module.exports = (env, argv) => { loader: "esbuild-loader", options: { target: "es6", + sourcemap: argv.mode !== "production", } }, { @@ -73,9 +77,15 @@ module.exports = (env, argv) => { MiniCssExtractPlugin.loader, { loader: "css-loader", // translates CSS into CommonJS + options: { + sourceMap: argv.mode !== "production", + }, }, { loader: "sass-loader", // compiles Sass to CSS + options: { + sourceMap: argv.mode !== "production", + }, }, ], },