summaryrefslogtreecommitdiffstats
path: root/resources/resource_transformers/tocss
AgeCommit message (Collapse)Author
2023-06-19tocss/dartsas: Avoid using Logf for the internal Dart Sass loggingBjørn Erik Pedersen
As that does not work when percentages are used in the log messages.
2023-06-18Replace the old log setup, with structured logging etc.Bjørn Erik Pedersen
Fixes #11124
2023-06-12Upgrade to v2 of the Dart Sass Embedded ProtocolBjørn Erik Pedersen
Fixes #11059
2023-06-12Fix indented SASS imports for Dart SassBjørn Erik Pedersen
Fixes #11074
2023-05-18all: Fix comments for exported functions and packagesOleksandr Redko
2023-05-16Create a struct with all of Hugo's config optionsBjørn Erik Pedersen
Primary motivation is documentation, but it will also hopefully simplify the code. Also, * Lower case the default output format names; this is in line with the custom ones (map keys) and how it's treated all the places. This avoids doing `stringds.EqualFold` everywhere. Closes #10896 Closes #10620
2023-02-24dartsass: Import CSS without extension at compile timeJoe Mooring
Applicable to Dart Sass only: - Sass imports with the .css extension indicate a plain CSS @import. - Sass imports without the .css extension are imported at compile time. Fixes #10592
2023-02-23sass: Remove some unused leftover codeBjørn Erik Pedersen
2023-02-23resources/sass: Remove debug statementsJoe Mooring
Closes #10470
2023-02-22tocss: Simplify the hugo:vars type handlingBjørn Erik Pedersen
Instead of maintaing a list of all CSS units and functions this commit: * Uses 3 regexps to detect typed CSS values (e.g. `24px`) + properly handle numeric Go types. * These regexps may have some false positives -- e.g. strings that needs to be quoted. * For that rare case, you can mark the string with e.g. `"32xxx" | css.Quoted` * For the opposite case: `"32" | css.Unquoted` Updates #10632
2023-02-22resource_transformers/tocss: Fixed hugo:vars castingAcClassic
Variables passed via the hugo:vars function where passed as type string. This caused problems when using the variables in sass functions because these expect a specific type. Now we check if the passed variables have to be quoted and therefore are of type string or if they should not be quoted and let the type interpretation up to the sass compiler. Fixes #10632
2022-12-21tocss: Add some more test casesBjørn Erik Pedersen
See #10555
2022-12-21tocss: Fix unquote case with double quotesSepts
See #10555
2022-12-20tocss: Add vars optionBjørn Erik Pedersen
This commit adds a new `vars` option to both the Sass transpilers (Dart Sass and Libsass). This means that you can pass a map with key/value pairs to the transpiler: ```handlebars {{ $vars := dict "$color1" "blue" "$color2" "green" "$font_size" "24px" }} {{ $cssOpts := (dict "transpiler" "dartsass" "outputStyle" "compressed" "vars" $vars ) }} {{ $r := resources.Get "scss/main.scss" | toCSS $cssOpts }} ``` And the the variables will be available in the `hugo:vars` namespace. Example usage for Dart Sass: ```scss @use "hugo:vars" as v; p { color: v.$color1; font-size: v.$font_size; } ``` Note that Libsass does not support the `use` keyword, so you need to `import` them as global variables: ```scss @import "hugo:vars"; p { color: $color1; font-size: $font_size; } ``` Hugo will: * Add a missing leading `$` for the variable names if needed. * Wrap the values in `unquote('VALUE')` (Sass built-in) to get proper handling of identifiers vs other strings. This means that you can pull variables directly from e.g. the site config: ```toml [params] [params.sassvars] color1 = "blue" color2 = "green" font_size = "24px" image = "images/hero.jpg" ``` ```handlebars {{ $vars := site.Params.sassvars}} {{ $cssOpts := (dict "transpiler" "dartsass" "outputStyle" "compressed" "vars" $vars ) }} {{ $r := resources.Get "scss/main.scss" | toCSS $cssOpts }} ``` Fixes #10555
2022-12-05dartsass: Add sourceMapIncludeSources optionBjørn Erik Pedersen
2022-09-06scss: Handle single-file sourcemaps correctlyJenny Rakoczy
Simple sites may only have one css file. Update the replace directive to correctly match single-file sourcemaps and multi-file sourcemaps. Verified locally with and without SASS and CSS imports. Fixes #8174
2022-05-27github: Set HUGO_BUILD_TAGS: extended when running testsBjørn Erik Pedersen
Also fix TestDecodeConfig/Basic which started to fail in the extended build in 0.99.1. Closes #9935
2022-05-15Improve SASS errorsBjørn Erik Pedersen
Fixes #9897
2022-05-15postcss: Fix import error handlingBjørn Erik Pedersen
Note that we will now fail if `inlineImports` is enabled and we cannot resolve an import. You can work around this by either: * Use url imports or imports with media queries. * Set `skipInlineImportsNotFound=true` in the options Also get the argument order in the different NewFileError* funcs in line. Fixes #9895
2022-05-14errors: Misc improvementsBjørn Erik Pedersen
* Redo the server error template * Always add the content file context if relevant * Remove some now superflous error string matching * Move the server error template to _server/error.html * Add file context (with position) to codeblock render blocks * Improve JS build errors Fixes #9892 Fixes #9891 Fixes #9893
2022-05-06Improve error messages, esp. when the server is runningBjørn Erik Pedersen
* Add file context to minifier errors when publishing * Misc fixes (see issues) * Allow custom server error template in layouts/server/error.html To get to this, this commit also cleans up and simplifies the code surrounding errors and files. This also removes the usage of `github.com/pkg/errors`, mostly because of https://github.com/pkg/errors/issues/223 -- but also because most of this is now built-in to Go. Fixes #9852 Fixes #9857 Fixes #9863
2022-03-17all: gofmt -w -r 'interface{} -> any' .Bjørn Erik Pedersen
Updates #9687
2022-03-17dartsass: Enable deprecation, @warn and @debug loggingBjørn Erik Pedersen
* @warn and Sass deprecations are printed as WARN * @debug is currently logged as INFO (needs the `--verbose` flag). We may adjust this if it gets too chatty. Fixes #9683
2022-03-15dartsass: Improve error message when no read accessBjørn Erik Pedersen
Fixes #9662
2022-02-10Simplify some integration testsBjørn Erik Pedersen
2022-02-09tocss: Port integration tests to their packageBjørn Erik Pedersen
2021-12-16Add some basic security policies with sensible defaultsBjørn Erik Pedersen
This ommmit contains some security hardening measures for the Hugo build runtime. There are some rarely used features in Hugo that would be good to have disabled by default. One example would be the "external helpers". For `asciidoctor` and some others we use Go's `os/exec` package to start a new process. These are a predefined set of binary names, all loaded from `PATH` and with a predefined set of arguments. Still, if you don't use `asciidoctor` in your project, you might as well have it turned off. You can configure your own in the new `security` configuration section, but the defaults are configured to create a minimal amount of site breakage. And if that do happen, you will get clear instructions in the loa about what to do. The default configuration is listed below. Note that almost all of these options are regular expression _whitelists_ (a string or a slice); the value `none` will block all. ```toml [security] enableInlineShortcodes = false [security.exec] allow = ['^dart-sass-embedded$', '^go$', '^npx$', '^postcss$'] osEnv = ['(?i)^(PATH|PATHEXT|APPDATA|TMP|TEMP|TERM)$'] [security.funcs] getenv = ['^HUGO_'] [security.http] methods = ['(?i)GET|POST'] urls = ['.*'] ```
2021-07-15hugofs: Make FileMeta a structBjørn Erik Pedersen
This commit started out investigating a `concurrent map read write` issue, ending by replacing the map with a struct. This is easier to reason about, and it's more effective: ``` name old time/op new time/op delta SiteNew/Regular_Deep_content_tree-16 71.5ms ± 3% 69.4ms ± 5% ~ (p=0.200 n=4+4) name old alloc/op new alloc/op delta SiteNew/Regular_Deep_content_tree-16 29.7MB ± 0% 27.9MB ± 0% -5.82% (p=0.029 n=4+4) name old allocs/op new allocs/op delta SiteNew/Regular_Deep_content_tree-16 313k ± 0% 303k ± 0% -3.35% (p=0.029 n=4+4) ``` See #8749
2020-12-31dartsass: Add missing OutputStyle optionBjørn Erik Pedersen
2020-12-30Add Dart Sass supportBjørn Erik Pedersen
But note that the Dart Sass Embedded Protocol is still in beta (beta 5), a main release scheduled for Q1 2021. Fixes #7380 Fixes #8102
2020-12-03all: Format code with gofumptBjørn Erik Pedersen
See https://github.com/mvdan/gofumpt
2020-11-13js: Let ESBuild handle all imports from node_modulesBjørn Erik Pedersen
This commit fixes some issues where modules in /assets share the same name as in node_modules. This was not intended, and with this commit the node_modules-components should be isolated. If you want to redefine something inside node_modules, use the `defines` option. Fixes #7948
2020-03-17resources: Fix scss vs css import regexpBjørn Erik Pedersen
Fixes #7063
2020-03-16Add workaround for regular CSS imports in SCSSBjørn Erik Pedersen
Fixes #7059
2020-02-10Update to LibSass v3.6.3Bjørn Erik Pedersen
Fixes #6862
2019-08-26Image resource refactorBjørn Erik Pedersen
This commit pulls most of the image related logic into its own package, to make it easier to reason about and extend. This is also a rewrite of the transformation logic used in Hugo Pipes, mostly to allow constructs like the one below: {{ ($myimg | fingerprint ).Width }} Fixes #5903 Fixes #6234 Fixes #6266
2019-07-24Add Hugo ModulesBjørn Erik Pedersen
This commit implements Hugo Modules. This is a broad subject, but some keywords include: * A new `module` configuration section where you can import almost anything. You can configure both your own file mounts nd the file mounts of the modules you import. This is the new recommended way of configuring what you earlier put in `configDir`, `staticDir` etc. And it also allows you to mount folders in non-Hugo-projects, e.g. the `SCSS` folder in the Bootstrap GitHub project. * A module consists of a set of mounts to the standard 7 component types in Hugo: `static`, `content`, `layouts`, `data`, `assets`, `i18n`, and `archetypes`. Yes, Theme Components can now include content, which should be very useful, especially in bigger multilingual projects. * Modules not in your local file cache will be downloaded automatically and even "hot replaced" while the server is running. * Hugo Modules supports and encourages semver versioned modules, and uses the minimal version selection algorithm to resolve versions. * A new set of CLI commands are provided to manage all of this: `hugo mod init`, `hugo mod get`, `hugo mod graph`, `hugo mod tidy`, and `hugo mod vendor`. All of the above is backed by Go Modules. Fixes #5973 Fixes #5996 Fixes #6010 Fixes #5911 Fixes #5940 Fixes #6074 Fixes #6082 Fixes #6092
2019-01-02resources: Move resource interfaces into its own packageBjørn Erik Pedersen