aboutsummaryrefslogtreecommitdiffhomepage
path: root/resources/resource_transformers
diff options
context:
space:
mode:
authorBjørn Erik Pedersen <[email protected]>2022-12-22 09:43:53 +0100
committerBjørn Erik Pedersen <[email protected]>2022-12-22 12:43:50 +0100
commit59af05cabc74e381afb62e624afa5542a9ae8d68 (patch)
tree444fb9c276172731a5cb8f6de52adaf21bafc21b /resources/resource_transformers
parent4989da653d601dcb539338f7e12ae825ce4a0db9 (diff)
downloadhugo-59af05cabc74e381afb62e624afa5542a9ae8d68.tar.gz
hugo-59af05cabc74e381afb62e624afa5542a9ae8d68.zip
Add HUGO_PUBLISHDIR to the Node environment
So you can do `process.env.HUGO_PUBLISHDIR` in your `postcss.config.js` to figure out where Hugo publishes its files. Note that the value will always be an absolute file path and will point to a directory on disk even when running `hugo server` in memory mode. If you write to this folder from PostCSS when running the server, you could run the server with one of these flags: ``` hugo server --renderToDisk hugo server --renderStaticToDisk ``` Fixes #10554
Diffstat (limited to 'resources/resource_transformers')
-rw-r--r--resources/resource_transformers/postcss/integration_test.go7
1 files changed, 5 insertions, 2 deletions
diff --git a/resources/resource_transformers/postcss/integration_test.go b/resources/resource_transformers/postcss/integration_test.go
index ab48297e4..cfe5f8a2c 100644
--- a/resources/resource_transformers/postcss/integration_test.go
+++ b/resources/resource_transformers/postcss/integration_test.go
@@ -85,6 +85,7 @@ Styles Content: Len: {{ len $styles.Content }}|
}
-- postcss.config.js --
console.error("Hugo Environment:", process.env.HUGO_ENVIRONMENT );
+console.error("Hugo PublishDir:", process.env.HUGO_PUBLISHDIR );
// https://github.com/gohugoio/hugo/issues/7656
console.error("package.json:", process.env.HUGO_FILE_PACKAGE_JSON );
console.error("PostCSS Config File:", process.env.HUGO_FILE_POSTCSS_CONFIG_JS );
@@ -118,8 +119,6 @@ func TestTransformPostCSS(t *testing.T) {
files := repl.Replace(postCSSIntegrationTestFiles)
- fmt.Println("===>", s, files)
-
b := hugolib.NewIntegrationTestBuilder(
hugolib.IntegrationTestConfig{
T: c,
@@ -135,6 +134,10 @@ Styles RelPermalink: /foo/css/styles.css
Styles Content: Len: 770917|
`)
+ if s == "never" {
+ b.AssertLogContains("Hugo Environment: production")
+ b.AssertLogContains("Hugo PublishDir: " + filepath.Join(tempDir, "public"))
+ }
}
}