diff --git a/packages/core/admin/index.js b/packages/core/admin/index.js index 922e1e7bfc..23fa8f7750 100644 --- a/packages/core/admin/index.js +++ b/packages/core/admin/index.js @@ -31,6 +31,7 @@ async function build({ appDir, buildDestDir, env, forceBuild, optimize, options, const dest = path.resolve(buildDestDir, 'build'); const pluginsPath = Object.keys(plugins).map((pluginName) => plugins[pluginName].pathToPlugin); + const enforceSourceMaps = process.env.STRAPI_ENFORCE_SOURCEMAPS === 'true' ?? false; // Either use the tsconfig file from the generated app or the one inside the .cache folder // so we can develop plugins in TS while being in a JS app @@ -42,6 +43,7 @@ async function build({ appDir, buildDestDir, env, forceBuild, optimize, options, appDir, cacheDir, dest, + enforceSourceMaps, entry, env, optimize, diff --git a/packages/core/admin/scripts/build.js b/packages/core/admin/scripts/build.js index 47864dece1..e13e87ca7a 100644 --- a/packages/core/admin/scripts/build.js +++ b/packages/core/admin/scripts/build.js @@ -54,6 +54,7 @@ const buildAdmin = async () => { telemetryDisabled: process.env.STRAPI_TELEMETRY_DISABLED === 'true' ?? false, }, tsConfigFilePath, + enforceSourceMaps: process.env.STRAPI_ENFORCE_SOURCEMAPS === 'true' ?? false, }; const config = diff --git a/packages/core/admin/webpack.config.js b/packages/core/admin/webpack.config.js index 340251794e..8eec36e906 100644 --- a/packages/core/admin/webpack.config.js +++ b/packages/core/admin/webpack.config.js @@ -28,6 +28,7 @@ module.exports = ({ features: [], }, tsConfigFilePath, + enforceSourceMaps, }) => { const isProduction = env === 'production'; @@ -54,7 +55,7 @@ module.exports = ({ return { mode: isProduction ? 'production' : 'development', bail: !!isProduction, - devtool: isProduction ? false : 'eval-source-map', + devtool: isProduction && !enforceSourceMaps ? false : 'source-map', experiments: { topLevelAwait: true, },