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
|
test-results.xml
|
||||||
/influxdb3cli-build-scripts/content
|
/influxdb3cli-build-scripts/content
|
||||||
.vscode/*
|
.vscode/*
|
||||||
|
!.vscode/launch.json
|
||||||
.idea
|
.idea
|
||||||
**/config.toml
|
**/config.toml
|
||||||
package-lock.json
|
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
|
# Production asset processing
|
||||||
build:
|
build:
|
||||||
writeStats: false
|
writeStats: false
|
||||||
useResourceCacheWhen: "always"
|
useResourceCacheWhen: "fallback"
|
||||||
buildOptions:
|
buildOptions:
|
||||||
sourcemap: false
|
sourcemap: false
|
||||||
target: "es2015"
|
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
|
# Disable development server settings
|
||||||
server: {}
|
server: {}
|
||||||
|
|
||||||
|
# Suppress the warning mentioned in the error
|
||||||
|
ignoreLogs:
|
||||||
|
- 'warning-goldmark-raw-html'
|
|
@ -5,9 +5,9 @@
|
||||||
<!-- Get site data -->
|
<!-- Get site data -->
|
||||||
<!-- Load cloudUrls array -->
|
<!-- Load cloudUrls array -->
|
||||||
{{ $cloudUrls := slice }}
|
{{ $cloudUrls := slice }}
|
||||||
{{- range.Site.Data.influxdb_urls.cloud.providers }}
|
{{- range .Site.Data.influxdb_urls.cloud.providers }}
|
||||||
{{- range.regions }}
|
{{- range .regions }}
|
||||||
{{ $cloudUrls = $cloudUrls | append "{{ safeHTML .url }}" }}
|
{{ $cloudUrls = $cloudUrls | append (safeHTML .url) }}
|
||||||
{{ end -}}
|
{{ end -}}
|
||||||
{{ end -}}
|
{{ end -}}
|
||||||
{{ $products := .Site.Data.products }}
|
{{ $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) }}
|
{{ $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 }}
|
{{ 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 }}
|
{{ $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 */}}
|
{{/* Load main.js first to ensure proper initialization */}}
|
||||||
{{ with resources.Get "js/main.js" }}
|
{{ $mainJS := resources.Get "js/main.js" }}
|
||||||
|
{{ if $mainJS }}
|
||||||
{{ $opts := dict
|
{{ $opts := dict
|
||||||
"minify" false
|
"minify" false
|
||||||
"sourceMap" "inline"
|
"sourceMap" "external"
|
||||||
"targetPath" "js/main.js"
|
"targetPath" "js/main.js"
|
||||||
"params" $sharedParams
|
"params" $sharedParams
|
||||||
|
"format" "esm"
|
||||||
|
"external" (slice "*")
|
||||||
|
"define" (dict
|
||||||
|
"process.env.NODE_ENV" "\"development\""
|
||||||
|
)
|
||||||
|
"splitting" false
|
||||||
|
"bundle" true
|
||||||
}}
|
}}
|
||||||
{{ with . | js.Build $opts }}
|
{{ $processed := $mainJS | js.Build $opts }}
|
||||||
<script defer src="{{ .RelPermalink }}"></script>
|
{{ if $processed }}
|
||||||
|
<script type="module" src="{{ $processed.RelPermalink }}"></script>
|
||||||
{{ end }}
|
{{ end }}
|
||||||
{{ end }}
|
{{ end }}
|
||||||
|
|
||||||
{{/* Load other individual JS files for debugging */}}
|
{{/* Load other individual JS files for debugging with error handling */}}
|
||||||
{{ range $file := (readDir "assets/js") }}
|
{{ $jsDir := "assets/js" }}
|
||||||
{{ if and (strings.HasSuffix $file.Name ".js") (ne $file.Name "main.js") }}
|
{{ if fileExists $jsDir }}
|
||||||
{{ $jsPath := printf "js/%s" $file.Name }}
|
{{ range $file := (readDir $jsDir) }}
|
||||||
{{ with resources.Get $jsPath }}
|
{{ if and (strings.HasSuffix $file.Name ".js") (ne $file.Name "main.js") }}
|
||||||
{{ $opts := dict
|
{{ $jsPath := printf "js/%s" $file.Name }}
|
||||||
"minify" false
|
{{ $jsResource := resources.Get $jsPath }}
|
||||||
"sourceMap" "inline"
|
{{ if $jsResource }}
|
||||||
"targetPath" $jsPath
|
{{ $opts := dict
|
||||||
"params" $sharedParams
|
"minify" false
|
||||||
}}
|
"sourceMap" "external"
|
||||||
{{ with . | js.Build $opts }}
|
"targetPath" $jsPath
|
||||||
<script defer src="{{ .RelPermalink }}"></script>
|
"params" $sharedParams
|
||||||
|
"format" "esm"
|
||||||
|
"external" (slice "*")
|
||||||
|
"define" (dict
|
||||||
|
"process.env.NODE_ENV" "\"development\""
|
||||||
|
)
|
||||||
|
"splitting" false
|
||||||
|
"bundle" true
|
||||||
|
}}
|
||||||
|
{{ $processed := $jsResource | js.Build $opts }}
|
||||||
|
{{ if $processed }}
|
||||||
|
<script type="module" src="{{ $processed.RelPermalink }}"></script>
|
||||||
|
{{ end }}
|
||||||
{{ end }}
|
{{ end }}
|
||||||
{{ end }}
|
{{ end }}
|
||||||
{{ end }}
|
{{ end }}
|
||||||
{{ end }}
|
{{ end }}
|
||||||
{{ else }}
|
{{ else }}
|
||||||
{{/* Non-development environment: Bundle everything */}}
|
{{/* Production environment: Use IIFE for better compatibility */}}
|
||||||
{{ with resources.Get "js/main.js" }}
|
{{ $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
|
{{ $opts := dict
|
||||||
"minify" hugo.IsProduction
|
"minify" hugo.IsProduction
|
||||||
"sourceMap" (cond hugo.IsProduction "" "external")
|
"sourceMap" ""
|
||||||
"targetPath" "js/main.js"
|
"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 }}
|
{{ if hugo.IsProduction }}
|
||||||
{{ with . | fingerprint }}
|
{{ $fingerprinted := $processed | fingerprint }}
|
||||||
<script defer src="{{ .RelPermalink }}" integrity="{{ .Data.Integrity }}" crossorigin="anonymous"></script>
|
{{ if $fingerprinted }}
|
||||||
|
<script defer src="{{ $fingerprinted.RelPermalink }}" integrity="{{ $fingerprinted.Data.Integrity }}" crossorigin="anonymous"></script>
|
||||||
{{ end }}
|
{{ end }}
|
||||||
{{ else }}
|
{{ else }}
|
||||||
<script defer src="{{ .RelPermalink }}"></script>
|
<script defer src="{{ $processed.RelPermalink }}"></script>
|
||||||
{{ end }}
|
{{ end }}
|
||||||
{{ end }}
|
{{ end }}
|
||||||
{{ end }}
|
{{ end }}
|
||||||
|
|
Loading…
Reference in New Issue