summaryrefslogtreecommitdiffstats
path: root/hugolib
diff options
context:
space:
mode:
authorBjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com>2019-09-03 12:25:41 +0200
committerBjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com>2019-09-03 12:25:41 +0200
commit1b5c7e327c7f98cf8e9fff920f3328198f67a598 (patch)
tree62554fd6ed9ef0105204d1b96955900b4eb4b728 /hugolib
parent05d83b6c08089c20ca1d99bcd224188ed5d127d4 (diff)
hugolib: Add a Sass includePaths test
See #6274
Diffstat (limited to 'hugolib')
-rw-r--r--hugolib/resource_chain_test.go48
1 files changed, 48 insertions, 0 deletions
diff --git a/hugolib/resource_chain_test.go b/hugolib/resource_chain_test.go
index a65200525..fd1ee7e5e 100644
--- a/hugolib/resource_chain_test.go
+++ b/hugolib/resource_chain_test.go
@@ -168,6 +168,54 @@ T1: {{ $r.Content }}
}
+// https://github.com/gohugoio/hugo/issues/6274
+func TestSCSSWithIncludePathsSass(t *testing.T) {
+ if !scss.Supports() {
+ t.Skip("Skip SCSS")
+ }
+ c := qt.New(t)
+ workDir, clean, err := htesting.CreateTempDir(hugofs.Os, "hugo-scss-includepaths")
+ c.Assert(err, qt.IsNil)
+ defer clean()
+
+ v := viper.New()
+ v.Set("workingDir", workDir)
+ v.Set("theme", "mytheme")
+ b := newTestSitesBuilder(t).WithLogger(loggers.NewErrorLogger())
+ // Need to use OS fs for this.
+ b.Fs = hugofs.NewDefault(v)
+ b.WithWorkingDir(workDir)
+ b.WithViper(v)
+
+ hulmaDir := filepath.Join(workDir, "node_modules", "hulma")
+ scssDir := filepath.Join(workDir, "themes/mytheme/assets", "scss")
+ c.Assert(os.MkdirAll(hulmaDir, 0777), qt.IsNil)
+ c.Assert(os.MkdirAll(scssDir, 0777), qt.IsNil)
+
+ b.WithSourceFile(filepath.Join(scssDir, "main.scss"), `
+@import "hulma/hulma";
+
+`)
+
+ b.WithSourceFile(filepath.Join(hulmaDir, "hulma.sass"), `
+$hulma: #ccc;
+
+foo
+ color: $hulma;
+
+`)
+
+ b.WithTemplatesAdded("index.html", `
+ {{ $scssOptions := (dict "targetPath" "css/styles.css" "enableSourceMap" false "includePaths" (slice "node_modules")) }}
+{{ $r := resources.Get "scss/main.scss" | toCSS $scssOptions | minify }}
+T1: {{ $r.Content }}
+`)
+ b.Build(BuildCfg{})
+
+ b.AssertFileContent(filepath.Join(workDir, "public/index.html"), `T1: foo{color:#ccc}`)
+
+}
+
func TestResourceChainBasic(t *testing.T) {
t.Parallel()