summaryrefslogtreecommitdiffstats
path: root/hugolib/resource_chain_babel_test.go
diff options
context:
space:
mode:
authorAndreas Richter <richtera@users.noreply.github.com>2021-01-18 04:38:09 -0500
committerGitHub <noreply@github.com>2021-01-18 10:38:09 +0100
commit2c8b5d9165011c4b24b494e661ae60dfc7bb7d1b (patch)
tree1fccfe098c0ad5a85a030ba918914ea4191c658c /hugolib/resource_chain_babel_test.go
parent0004a733c85cee991a8a170e93cd69c326cc8f2f (diff)
pipes: Add external source map support to js.Build and Babel
Fixes #8132
Diffstat (limited to 'hugolib/resource_chain_babel_test.go')
-rw-r--r--hugolib/resource_chain_babel_test.go33
1 files changed, 33 insertions, 0 deletions
diff --git a/hugolib/resource_chain_babel_test.go b/hugolib/resource_chain_babel_test.go
index d5e99cd17..77c81f9ca 100644
--- a/hugolib/resource_chain_babel_test.go
+++ b/hugolib/resource_chain_babel_test.go
@@ -80,6 +80,15 @@ class Car {
}
`
+ js2 := `
+/* A Car2 */
+class Car2 {
+ constructor(brand) {
+ this.carname = brand;
+ }
+}
+`
+
workDir, clean, err := htesting.CreateTempDir(hugofs.Os, "hugo-test-babel")
c.Assert(err, qt.IsNil)
defer clean()
@@ -103,11 +112,18 @@ class Car {
{{ $transpiled := resources.Get "js/main.js" | babel -}}
Transpiled: {{ $transpiled.Content | safeJS }}
+{{ $transpiled := resources.Get "js/main2.js" | babel (dict "sourceMap" "inline") -}}
+Transpiled2: {{ $transpiled.Content | safeJS }}
+
+{{ $transpiled := resources.Get "js/main2.js" | babel (dict "sourceMap" "external") -}}
+Transpiled3: {{ $transpiled.Permalink }}
+
`)
jsDir := filepath.Join(workDir, "assets", "js")
b.Assert(os.MkdirAll(jsDir, 0777), qt.IsNil)
b.WithSourceFile("assets/js/main.js", js)
+ b.WithSourceFile("assets/js/main2.js", js2)
b.WithSourceFile("package.json", packageJSON)
b.WithSourceFile("babel.config.js", babelConfig)
@@ -129,4 +145,21 @@ var Car = function Car(brand) {
this.carname = brand;
};
`)
+ b.AssertFileContent("public/index.html", `
+var Car2 = function Car2(brand) {
+ _classCallCheck(this, Car2);
+
+ this.carname = brand;
+};
+`)
+ b.AssertFileContent("public/js/main2.js", `
+var Car2 = function Car2(brand) {
+ _classCallCheck(this, Car2);
+
+ this.carname = brand;
+};
+`)
+ b.AssertFileContent("public/js/main2.js.map", `{"version":3,`)
+ b.AssertFileContent("public/index.html", `
+//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozL`)
}