summaryrefslogtreecommitdiffstats
path: root/resources/resource_transformers
AgeCommit message (Collapse)Author
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-06-12js: Resolve index.esm.jsBjørn Erik Pedersen
Same logic as for `index.{js,ts...}` files applies; if both `index.esm.js` and `index.js` exists (unlikely), you need to use the name with extension when importing, else the `index.js` will win. Fixes #8631
2022-05-27Don't use the baseURL /path as part of the resource cache keyBjørn Erik Pedersen
As that prevents Hugo projects with sub paths in their `baseURL` to use themes with cached resources. Fixes #9787
2022-05-27postcss: Make the resource cache key more stableBjørn Erik Pedersen
By using the input map as the basis, which means the hash will not change if we add/rename/remove options. This happened in Hugo 0.99, as we added a new options. This is unortunate. Unfortunately this means that the cache keys for PostCSS will change one more time in 0.100, but will be stable going forward. Note that we have implemented this pattern in all the other resource transformers. Updates #9787
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-25Fix error message when PostCSS config file is not foundBjørn Erik Pedersen
Fixes #9927
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-14postcss: Fix line numbers in error messagesBjørn Erik Pedersen
Fixes #9880
2022-05-13js: Bump test dependencyBjørn Erik Pedersen
To work around a cache issue.
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-04-08Rework the Destination filesystem to make --renderStaticToDisk workBjørn Erik Pedersen
See #9626
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-03-09minifiers: Make keepWhitespace = false default for HTML (note)Joe Mooring
Closes #9456
2022-02-10Simplify some integration testsBjørn Erik Pedersen
2022-02-09babel: Port integration tests to their own packageBjørn Erik Pedersen
2022-02-09js: Port integration tests to its own packageBjørn Erik Pedersen
2022-02-09postcss: Move integration test to its own packageBjørn Erik Pedersen
2022-02-09minifier: Port integration tests to its packageBjørn Erik Pedersen
2022-02-09templates: Port integration test to its packageBjø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-10-10Allow multiple plugins in the PostCSS options mapJoe Mooring
Usage: {{ $options := dict "use" "autoprefixer postcss-color-alpha" }} {{ $style := resources.Get "main.css" | resources.PostCSS $options }} Fixes #9015
2021-09-22Pass minification errors to the userPaul Gottschling
Previously, *minifyTransformation.Transform suppressed the error returned by t.m.Minify. This meant that when minification returned an error, the error would not reach the user. Instead, minification would silently fail. For example, if a JavaScript file included a call to the Date constructor with: new Date(2020, 04, 02) The package that the minification library uses to parse JS files, github.com/tdewolff/parse would return an error, since "04" would be parsed as a legacy octal. However, the JS file would remain un-minified with no error. Fixing this is not as simple as replacing "_" with an "err" in *minifyTransformation.Transform, however (though this is necessary). If we only returned this error from Transform, then hugolib.TestResourceMinifyDisabled would fail. Instead of being a no-op, as TestResourceMinifyDisabled expects, using the "minify" template function with a "disableXML=true" config setting instead returns the error, "minifier does not exist for mimetype." The "minifier does not exist" error is returned because of the way minifiers.New works. If the user's config disables minification for a particular MIME type, minifiers.New does not add it to the resulting Client's *minify.M. However, this also means that when the "minify" template function is executed, a *resourceAdapter's transformations still add a minification. When it comes time to call the minify.Minifier for a specific MIME type via *M.MinifyMimetype, the github.com/tdewolff/minify library throws the "does not exist" error for the missing MIME type. The solution was to change minifiers.New so, instead of skipping a minifier for each disabled MIME type, it adds a NoOpMinifier, which simply copies the source to the destination without minification. This means that when the "minify" template function is used for a particular resource, and that resource's MIME type has minification disabled, minification is genuinely skipped, and does not result in an error. In order to add this, I've fixed a possibly unwanted interaction between minifiers.TestConfigureMinify and hugolib.TestResourceMinifyDisabled. The latter disables minification and expects minification to be a no-op. The former disables minification and expects it to result in an error. The only reason hugolib.TestResourceMinifyDisabled passes in the original code is that the "does not exist" error is suppressed. However, we shouldn't suppress minification errors, since they can leave users perplexed. I've changed the test assertion in minifiers.TestConfigureMinify to expect no errors and a no-op if minification is disabled for a particular MIME type. Fixes #8954
2021-09-01js: Fix import order for ./foo when both ./foo.js and ./foo/index.js existsBjørn Erik Pedersen
This is in line with how both Node and ESBuild's native import resolver does it. The ambiguous situations above were discovered trying to build AlpineJS v3. Note that the above was never an issue if you used `./foo.js` and similar to import the component. Fixes #8945
2021-07-19minifiers: Make keepWhitespace = true default for HTMLBjørn Erik Pedersen
Fixes #8771
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
2021-06-14Misc config loading fixesBjørn Erik Pedersen
The main motivation behind this is simplicity and correctnes, but the new small config library is also faster: ``` BenchmarkDefaultConfigProvider/Viper-16 252418 4546 ns/op 2720 B/op 30 allocs/op BenchmarkDefaultConfigProvider/Custom-16 450756 2651 ns/op 1008 B/op 6 allocs/op ``` Fixes #8633 Fixes #8618 Fixes #8630 Updates #8591 Closes #6680 Closes #5192
2021-03-14deps: Update to esbuild v0.9.0Bjørn Erik Pedersen
2021-02-16js: Fix potential path issue on WindowsBjørn Erik Pedersen
2021-02-01deps: Update to esbuild v0.8.39Bjørn Erik Pedersen
Fixes #8189
2021-01-22js: Add Inject config optionBjørn Erik Pedersen
Fixes #8164
2021-01-22js: Add Shims optionBjørn Erik Pedersen
This commit adds a new `shims` option to `js.Build` that allows swapping out a component with another. Fixes #8165
2021-01-21Fix nilpointer in js.Build error handlingBjørn Erik Pedersen
Fixes #8162
2021-01-18pipes: Add external source map support to js.Build and BabelAndreas Richter
Fixes #8132
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-19Improve LookPathBjørn Erik Pedersen
2020-12-16all: Fix minor typosPhil Davis
2020-12-03all: Format code with gofumptBjørn Erik Pedersen
See https://github.com/mvdan/gofumpt
2020-11-25deps: Update to github.com/evanw/esbuild 0.8.11 to 0.8.14Bjørn Erik Pedersen
Closes #7986
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-11-04js: Remove external source map optionBjørn Erik Pedersen
It was merged by accident and the implementation does not look correct. Fixes #7932
2020-11-04js: Misc fixesBjørn Erik Pedersen
* Fix resolve of package.json deps in submodules * Fix directory logic for writing assets/jsconfig.json Fixes #7924 Fixes #7923
2020-11-03js: Add avoidTDZ optionBjørn Erik Pedersen
Fixes #7865
2020-11-03Make js.Build fully support modulesBjørn Erik Pedersen
Fixes #7816 Fixes #7777 Fixes #7916
2020-11-03js.Build: Generate tsconfig filesAndreas Richter
Updates #7777 Added support to allow SourceMap files to be external to the build. In addition added more information when the js compilation has an error. Correctly append sourceMappingURL to output file. Fix merge conflict.