fix(ci): Disable unnecessary SCSS processing when building JS assets.
- Build resources if not cached - Ensure node_modules dependencies are available for asset processing - Be more precise in the template when building assets in production mode and avoid conflicts with SCSS and CSS processing. - Ignore node_modules when loading source maps - Add .vscode/launch.json with debugging configuration for localhost:1313. In VSCode, go to Run and select the site to launch Chrome, connect to Developer Tools, and start debugging.pull/6079/head
parent
03fbbf6201
commit
c4d93ab249
|
@ -21,6 +21,7 @@ node_modules
|
|||
test-results.xml
|
||||
/influxdb3cli-build-scripts/content
|
||||
.vscode/*
|
||||
!.vscode/launch.json
|
||||
.idea
|
||||
**/config.toml
|
||||
package-lock.json
|
||||
|
|
|
@ -0,0 +1,19 @@
|
|||
{
|
||||
// Use IntelliSense to learn about possible attributes.
|
||||
// Hover to view descriptions of existing attributes.
|
||||
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
|
||||
"version": "0.2.0",
|
||||
"configurations": [
|
||||
{
|
||||
"type": "chrome",
|
||||
"request": "launch",
|
||||
"name": "Open Docs on localhost:1313",
|
||||
"url": "http://localhost:1313",
|
||||
"webRoot": "${workspaceFolder}",
|
||||
"skipFiles": [
|
||||
"<node_internals>/**",
|
||||
"${workspaceFolder}/node_modules/**"
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
|
@ -16,10 +16,25 @@ minify:
|
|||
# Production asset processing
|
||||
build:
|
||||
writeStats: false
|
||||
useResourceCacheWhen: "always"
|
||||
useResourceCacheWhen: "fallback"
|
||||
buildOptions:
|
||||
sourcemap: false
|
||||
target: "es2015"
|
||||
|
||||
# Asset processing configuration
|
||||
assetDir: "assets"
|
||||
|
||||
# Mount assets for production
|
||||
module:
|
||||
mounts:
|
||||
- source: assets
|
||||
target: assets
|
||||
- source: node_modules
|
||||
target: assets/node_modules
|
||||
|
||||
# Disable development server settings
|
||||
server: {}
|
||||
|
||||
# Suppress the warning mentioned in the error
|
||||
ignoreLogs:
|
||||
- 'warning-goldmark-raw-html'
|
|
@ -5,9 +5,9 @@
|
|||
<!-- Get site data -->
|
||||
<!-- Load cloudUrls array -->
|
||||
{{ $cloudUrls := slice }}
|
||||
{{- range.Site.Data.influxdb_urls.cloud.providers }}
|
||||
{{- range.regions }}
|
||||
{{ $cloudUrls = $cloudUrls | append "{{ safeHTML .url }}" }}
|
||||
{{- range .Site.Data.influxdb_urls.cloud.providers }}
|
||||
{{- range .regions }}
|
||||
{{ $cloudUrls = $cloudUrls | append (safeHTML .url) }}
|
||||
{{ end -}}
|
||||
{{ end -}}
|
||||
{{ $products := .Site.Data.products }}
|
||||
|
@ -16,55 +16,92 @@
|
|||
{{ $isDevelopmentOrTesting := or (eq .Site.Params.environment "development") (eq .Site.Params.environment "testing") (eq (getenv "HUGO_ENV") "development") (eq (getenv "HUGO_ENV") "testing") (not hugo.IsProduction) }}
|
||||
|
||||
{{ if $isDevelopmentOrTesting }}
|
||||
{{/* Load individual JS files for debugging */}}
|
||||
{{/* Load individual JS files for debugging with ESM format */}}
|
||||
{{ $sharedParams := dict "product" $product "currentVersion" $currentVersion "isServer" hugo.IsServer "products" $products "influxdb_urls" $influxdb_urls "cloudUrls" $cloudUrls }}
|
||||
|
||||
{{/* Load main.js first to ensure proper initialization */}}
|
||||
{{ with resources.Get "js/main.js" }}
|
||||
{{ $mainJS := resources.Get "js/main.js" }}
|
||||
{{ if $mainJS }}
|
||||
{{ $opts := dict
|
||||
"minify" false
|
||||
"sourceMap" "inline"
|
||||
"sourceMap" "external"
|
||||
"targetPath" "js/main.js"
|
||||
"params" $sharedParams
|
||||
"format" "esm"
|
||||
"external" (slice "*")
|
||||
"define" (dict
|
||||
"process.env.NODE_ENV" "\"development\""
|
||||
)
|
||||
"splitting" false
|
||||
"bundle" true
|
||||
}}
|
||||
{{ with . | js.Build $opts }}
|
||||
<script defer src="{{ .RelPermalink }}"></script>
|
||||
{{ $processed := $mainJS | js.Build $opts }}
|
||||
{{ if $processed }}
|
||||
<script type="module" src="{{ $processed.RelPermalink }}"></script>
|
||||
{{ end }}
|
||||
{{ end }}
|
||||
|
||||
{{/* Load other individual JS files for debugging */}}
|
||||
{{ range $file := (readDir "assets/js") }}
|
||||
{{/* Load other individual JS files for debugging with error handling */}}
|
||||
{{ $jsDir := "assets/js" }}
|
||||
{{ if fileExists $jsDir }}
|
||||
{{ range $file := (readDir $jsDir) }}
|
||||
{{ if and (strings.HasSuffix $file.Name ".js") (ne $file.Name "main.js") }}
|
||||
{{ $jsPath := printf "js/%s" $file.Name }}
|
||||
{{ with resources.Get $jsPath }}
|
||||
{{ $jsResource := resources.Get $jsPath }}
|
||||
{{ if $jsResource }}
|
||||
{{ $opts := dict
|
||||
"minify" false
|
||||
"sourceMap" "inline"
|
||||
"sourceMap" "external"
|
||||
"targetPath" $jsPath
|
||||
"params" $sharedParams
|
||||
"format" "esm"
|
||||
"external" (slice "*")
|
||||
"define" (dict
|
||||
"process.env.NODE_ENV" "\"development\""
|
||||
)
|
||||
"splitting" false
|
||||
"bundle" true
|
||||
}}
|
||||
{{ with . | js.Build $opts }}
|
||||
<script defer src="{{ .RelPermalink }}"></script>
|
||||
{{ $processed := $jsResource | js.Build $opts }}
|
||||
{{ if $processed }}
|
||||
<script type="module" src="{{ $processed.RelPermalink }}"></script>
|
||||
{{ end }}
|
||||
{{ end }}
|
||||
{{ end }}
|
||||
{{ end }}
|
||||
{{ end }}
|
||||
{{ else }}
|
||||
{{/* Non-development environment: Bundle everything */}}
|
||||
{{ with resources.Get "js/main.js" }}
|
||||
{{/* Production environment: Use IIFE for better compatibility */}}
|
||||
{{ $mainJS := resources.Get "js/main.js" }}
|
||||
{{ if $mainJS }}
|
||||
{{ $sharedParams := dict "product" $product "currentVersion" $currentVersion "isServer" hugo.IsServer "products" $products "influxdb_urls" $influxdb_urls "cloudUrls" $cloudUrls }}
|
||||
|
||||
{{ $opts := dict
|
||||
"minify" hugo.IsProduction
|
||||
"sourceMap" (cond hugo.IsProduction "" "external")
|
||||
"sourceMap" ""
|
||||
"targetPath" "js/main.js"
|
||||
"params" (dict "product" $product "currentVersion" $currentVersion "isServer" hugo.IsServer "products" $products "influxdb_urls" $influxdb_urls "cloudUrls" $cloudUrls)
|
||||
"params" $sharedParams
|
||||
"format" "iife"
|
||||
"splitting" false
|
||||
"external" (slice "*")
|
||||
"define" (dict
|
||||
"process.env.NODE_ENV" "\"production\""
|
||||
)
|
||||
}}
|
||||
{{ with . | js.Build $opts }}
|
||||
|
||||
{{ $processed := "" }}
|
||||
{{ with $mainJS }}
|
||||
{{ $processed = . | js.Build $opts }}
|
||||
{{ end }}
|
||||
|
||||
{{ if $processed }}
|
||||
{{ if hugo.IsProduction }}
|
||||
{{ with . | fingerprint }}
|
||||
<script defer src="{{ .RelPermalink }}" integrity="{{ .Data.Integrity }}" crossorigin="anonymous"></script>
|
||||
{{ $fingerprinted := $processed | fingerprint }}
|
||||
{{ if $fingerprinted }}
|
||||
<script defer src="{{ $fingerprinted.RelPermalink }}" integrity="{{ $fingerprinted.Data.Integrity }}" crossorigin="anonymous"></script>
|
||||
{{ end }}
|
||||
{{ else }}
|
||||
<script defer src="{{ .RelPermalink }}"></script>
|
||||
<script defer src="{{ $processed.RelPermalink }}"></script>
|
||||
{{ end }}
|
||||
{{ end }}
|
||||
{{ end }}
|
||||
|
|
Loading…
Reference in New Issue