I’d like to include modern-normalize.css
from GitHub - sindresorhus/modern-normalize: 🐒 Normalize browsers' default style into my styles.scss file. I feel like I’m close, but just not quite there. In config.toml, I’ve set it up as the following:
[module]
[[module.mounts]]
source = "assets"
target = "assets"
[[module.imports]]
path = "github.com/sindresorhus/modern-normalize"
[[module.imports.mounts]]
source = "modern-normalize.css"
target = "assets/scss/_modern-normalize.scss"
When I do that, I get the following error after running hugo serve
:
Module “GitHub - sindresorhus/modern-normalize: 🐒 Normalize browsers' default style” not found; either add it as a Hugo Module or store it in “/src/themes”.: module does not exist
I tried the following command: hugo mod get -u
and get the following:
go: downloading GitHub - sindresorhus/modern-normalize: 🐒 Normalize browsers' default style v1.0.0
go: GitHub - sindresorhus/modern-normalize: 🐒 Normalize browsers' default style upgrade => v1.0.0
But alas, I had the same error.
After that, I tried hugo mod init github.com/sindresorhus/modern-normalize
and it created a new go.mod file that looks like the following:
module github.com/sindresorhus/modern-normalize
go 1.14
Now, when I run hugo server
I don’t get any errors!
Now, to import modern-normalize.css
. In assets/scss/style.scss
, I have the following line:
@import 'modern-normalize';
In my partial, I process and import the css as follows:
{{ $sass := resources.Get "scss/style.scss" }}
{{ $cssTarget := "css/styles.css" }}
{{ $cssOpts. := (dict "targetPath" $cssTarget) }}
{{ $css := $sass | resources.ExecuteAsTemplate "main.scss" . | toCSS $cssOpts }}
<link rel="stylesheet" href="{{ $css.Permalink | absURL }}" media="screen">
As a result, I get the following error:
Error: Error building site: TOCSS: failed to transform “main.scss” (text/x-scss): SCSS processing failed: file “stdin”, line 1, col 1: File to import not found or unreadable: modern-normalize.
I’m new to modules, so I can’t tell if I’m going about this the right way or not. I’ve also tried different variations of the import (e.g. ./modern-normalize
, modern-normalize.scss
, modern-normalize.css
, etc.). Can someone point out where I’ve gone wrong?