Add devtool property for webpack
- Use inline-source-map for karma-webpack
This commit is contained in:
+2
@@ -23,6 +23,7 @@ import org.jetbrains.kotlin.gradle.targets.js.nodejs.NodeJsRootPlugin
|
||||
import org.jetbrains.kotlin.gradle.targets.js.npm.npmProject
|
||||
import org.jetbrains.kotlin.gradle.targets.js.testing.*
|
||||
import org.jetbrains.kotlin.gradle.targets.js.webpack.KotlinWebpackConfig
|
||||
import org.jetbrains.kotlin.gradle.targets.js.webpack.KotlinWebpackConfig.Devtool
|
||||
import org.jetbrains.kotlin.gradle.testing.internal.reportsDir
|
||||
import org.slf4j.Logger
|
||||
import java.io.File
|
||||
@@ -252,6 +253,7 @@ class KotlinKarma(override val compilation: KotlinJsCompilation) : KotlinJsTestF
|
||||
val webpackConfigWriter = KotlinWebpackConfig(
|
||||
configDirectory = project.projectDir.resolve("webpack.config.d").takeIf { it.isDirectory },
|
||||
sourceMaps = true,
|
||||
devtool = Devtool.INLINE_SOURCE_MAP,
|
||||
export = false,
|
||||
progressReporter = true,
|
||||
progressReporterPathFilter = nodeJs.rootPackageDir.absolutePath
|
||||
|
||||
+10
-3
@@ -25,7 +25,8 @@ data class KotlinWebpackConfig(
|
||||
val configDirectory: File? = null,
|
||||
val bundleAnalyzerReportDir: File? = null,
|
||||
val reportEvaluatedConfigFile: File? = null,
|
||||
var devServer: DevServer? = null,
|
||||
val devServer: DevServer? = null,
|
||||
val devtool: Devtool = Devtool.EVAL_SOURCE_MAP,
|
||||
val showProgress: Boolean = false,
|
||||
val sourceMaps: Boolean = false,
|
||||
val export: Boolean = true,
|
||||
@@ -75,6 +76,12 @@ data class KotlinWebpackConfig(
|
||||
val contentBase: List<String>
|
||||
) : Serializable
|
||||
|
||||
enum class Devtool(val code: String) {
|
||||
EVAL_SOURCE_MAP("eval-source-map"),
|
||||
SOURCE_MAP("source-map"),
|
||||
INLINE_SOURCE_MAP("inline-source-map")
|
||||
}
|
||||
|
||||
fun save(configFile: File) {
|
||||
configFile.writer().use {
|
||||
appendTo(it)
|
||||
@@ -173,7 +180,7 @@ data class KotlinWebpackConfig(
|
||||
if (devServer == null) return
|
||||
|
||||
appendln("// dev server")
|
||||
appendln("config.devServer = ${json(devServer!!)};")
|
||||
appendln("config.devServer = ${json(devServer)};")
|
||||
appendln()
|
||||
}
|
||||
|
||||
@@ -189,7 +196,7 @@ data class KotlinWebpackConfig(
|
||||
use: ["source-map-loader"],
|
||||
enforce: "pre"
|
||||
});
|
||||
config.devtool = 'eval-source-map';
|
||||
config.devtool = '${devtool.code}';
|
||||
|
||||
""".trimIndent()
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user