mirror of
https://github.com/gohugoio/hugo.git
synced 2025-08-17 21:01:26 +02:00
js.Build: Add SourceMap flag with inline option
Added a flag to allow turning on sourcemap in ESBuild. The current support can only support inline or true as value for sourcemap. This is because the way ESBuild is invoked it doesn't have a separate output path to write the mapfile external to the asset pipeline. Add disable for "" and "0". Add test script and make sure mage check passes. Fixes #7607
This commit is contained in:
@@ -42,6 +42,9 @@ type Options struct {
|
||||
// Whether to minify to output.
|
||||
Minify bool
|
||||
|
||||
// Whether to write mapfiles (currently inline only)
|
||||
SourceMap string
|
||||
|
||||
// The language target.
|
||||
// One of: es2015, es2016, es2017, es2018, es2019, es2020 or esnext.
|
||||
// Default is esnext.
|
||||
@@ -217,12 +220,24 @@ func toBuildOptions(opts Options) (buildOptions api.BuildOptions, err error) {
|
||||
defines = cast.ToStringMapString(opts.Defines)
|
||||
}
|
||||
|
||||
var sourceMap api.SourceMap
|
||||
switch opts.SourceMap {
|
||||
case "inline":
|
||||
sourceMap = api.SourceMapInline
|
||||
case "":
|
||||
sourceMap = api.SourceMapNone
|
||||
default:
|
||||
err = fmt.Errorf("unsupported sourcemap type: %q", opts.SourceMap)
|
||||
return
|
||||
}
|
||||
|
||||
buildOptions = api.BuildOptions{
|
||||
Outfile: "",
|
||||
Bundle: true,
|
||||
|
||||
Target: target,
|
||||
Format: format,
|
||||
Target: target,
|
||||
Format: format,
|
||||
Sourcemap: sourceMap,
|
||||
|
||||
MinifyWhitespace: opts.Minify,
|
||||
MinifyIdentifiers: opts.Minify,
|
||||
|
Reference in New Issue
Block a user