diff --git a/lib/compiler.js b/lib/compiler.js index 227d7a93..c2c00f27 100644 --- a/lib/compiler.js +++ b/lib/compiler.js @@ -42,20 +42,8 @@ exports.runWebpackCompiler = function runWebpackCompiler(config, $projectData, $ const envData = buildEnvData($projectData, platform, env); const envParams = buildEnvCommandLineParams(config, envData, $logger); - // Adding `npm i source-map-support --save-dev` in an app will make source maps work - // and stack traces will point to .ts if .ts files and proper source maps exist. - let sourceMapSupportArgs = []; - const appSourceMapSupportInstallPath = pathResolve(projectDir, "node_modules", "source-map-support", "register.js"); - const devDepSourceMapSupportInstallPath = pathResolve(__dirname, "..", "node_modules", "source-map-support", "register.js"); - if (existsSync(appSourceMapSupportInstallPath)) { - sourceMapSupportArgs = ["--require", appSourceMapSupportInstallPath]; - } else if (existsSync(devDepSourceMapSupportInstallPath)) { - sourceMapSupportArgs = ["--require", devDepSourceMapSupportInstallPath]; - } - const args = [ "--preserve-symlinks", - ...sourceMapSupportArgs, pathResolve(projectDir, "node_modules", "webpack", "bin", "webpack.js"), `--config=${pathResolve(projectDir, "webpack.config.js")}`, ...(config.watch ? ["--watch"] : []), diff --git a/templates/webpack.angular.js b/templates/webpack.angular.js index 97c3beb2..2a594d42 100644 --- a/templates/webpack.angular.js +++ b/templates/webpack.angular.js @@ -44,6 +44,7 @@ module.exports = env => { snapshot, // --env.snapshot uglify, // --env.uglify report, // --env.report + sourceMap, // --env.sourceMap } = env; const appFullPath = resolve(projectRoot, appPath); @@ -100,7 +101,7 @@ module.exports = env => { "fs": "empty", "__dirname": false, }, - devtool: "none", + devtool: sourceMap ? "inline-source-map" : "none", optimization: { splitChunks: { cacheGroups: { @@ -229,6 +230,7 @@ module.exports = env => { entryModule: resolve(appPath, "app.module#AppModule"), tsConfigPath: join(__dirname, "tsconfig.esm.json"), skipCodeGeneration: !aot, + sourceMap: !!sourceMap, }), // Does IPC communication with the {N} CLI to notify events when running in watch mode. new nsWebpack.WatchStateLoggerPlugin(), diff --git a/templates/webpack.javascript.js b/templates/webpack.javascript.js index 1700a92f..37251794 100644 --- a/templates/webpack.javascript.js +++ b/templates/webpack.javascript.js @@ -39,6 +39,7 @@ module.exports = env => { snapshot, // --env.snapshot uglify, // --env.uglify report, // --env.report + sourceMap, // --env.sourceMap } = env; const appFullPath = resolve(projectRoot, appPath); @@ -93,7 +94,7 @@ module.exports = env => { "fs": "empty", "__dirname": false, }, - devtool: "none", + devtool: sourceMap ? "inline-source-map" : "none", optimization: { splitChunks: { cacheGroups: { diff --git a/templates/webpack.typescript.js b/templates/webpack.typescript.js index 7394c84d..79ee37a5 100644 --- a/templates/webpack.typescript.js +++ b/templates/webpack.typescript.js @@ -39,6 +39,7 @@ module.exports = env => { snapshot, // --env.snapshot uglify, // --env.uglify report, // --env.report + sourceMap, // --env.sourceMap } = env; const appFullPath = resolve(projectRoot, appPath); @@ -95,7 +96,7 @@ module.exports = env => { "fs": "empty", "__dirname": false, }, - devtool: "none", + devtool: sourceMap ? "inline-source-map" : "none", optimization: { splitChunks: { cacheGroups: {