chore(js): Unbundle assets in Hugo development and testing environments:

- Keep assets unbundled for easier debugging in development and testing.
- Copies other config from development to testing.
pull/6079/head
Jason Stirnaman 2025-06-02 17:37:20 -05:00
parent c43df7508f
commit 13129c5687
6 changed files with 218 additions and 27 deletions

View File

@ -41,7 +41,7 @@ jobs:
- /home/circleci/bin
- run:
name: Hugo Build
command: npx hugo --logLevel info --minify --destination workspace/public
command: npx hugo --config config/production/config.yml --logLevel info --minify --destination workspace/public
- persist_to_workspace:
root: workspace
paths:

View File

@ -0,0 +1,25 @@
# Production overrides for CI/CD builds
baseURL: 'https://docs.influxdata.com/'
# Production environment parameters
params:
env: production
environment: production
# Enable minification for production
minify:
disableJS: false
disableCSS: false
disableHTML: false
minifyOutput: true
# Production asset processing
build:
writeStats: false
useResourceCacheWhen: "always"
buildOptions:
sourcemap: false
target: "es2015"
# Disable development server settings
server: {}

View File

@ -1,20 +1,111 @@
baseURL: 'http://localhost:1315/'
languageCode: en-us
title: InfluxDB Documentation
server:
port: 1315
# Git history information for lastMod-type functionality
enableGitInfo: true
# Syntax Highlighting
pygmentsCodefences: true
pygmentsUseClasses: true
# Preserve case in article tags
preserveTaxonomyNames: true
# Generate a robots.txt
enableRobotsTXT: true
# Override settings for testing
buildFuture: true
# Configure what content is built in testing env
params:
env: testing
environment: testing
buildTestContent: true
# Server configuration for testing
server:
port: 1315
baseURL: 'http://localhost:1315/'
watchChanges: true
disableLiveReload: false
# Keep your shared content exclusions
ignoreFiles:
- "content/shared/.*"
# Ignore specific warning logs
ignoreLogs:
- warning-goldmark-raw-html
- warning-goldmark-raw-html
# Markdown rendering options
blackfriday:
hrefTargetBlank: true
smartDashes: false
# Copy taxonomies from main config
taxonomies:
influxdb/v2/tag: influxdb/v2/tags
influxdb/cloud/tag: influxdb/cloud/tags
influxdb3/cloud-serverless/tag: influxdb/cloud-serverless/tags
influxdb3/cloud-dedicated/tag: influxdb/cloud-dedicated/tags
influxdb3/clustered/tag: influxdb3/clustered/tags
influxdb3/core/tag: influxdb3/core/tags
influxdb3/enterprise/tag: influxdb3/enterprise/tags
flux/v0/tag: flux/v0/tags
# Markup configuration
markup:
goldmark:
renderer:
unsafe: true
extensions:
linkify: false
parser:
attribute:
block: true
# Privacy settings
privacy:
googleAnalytics:
anonymizeIP: false
disable: false
respectDoNotTrack: true
useSessionStorage: false
youtube:
disable: false
privacyEnhanced: true
# Output formats
outputFormats:
json:
mediaType: application/json
baseName: pages
isPlainText: true
# Asset processing for testing (disable minification)
build:
writeStats: true
useResourceCacheWhen: "fallback"
buildOptions:
sourcemap: "inline"
target: "es2020"
# Disable minification for testing
minify:
disableJS: true
disableCSS: true
disableHTML: true
minifyOutput: false
# Asset processing configuration
assetDir: "assets"
# Module mounts
module:
mounts:
- source: assets
target: assets
- source: node_modules
target: assets/node_modules

View File

@ -17,7 +17,26 @@ enableRobotsTXT: true
# Custom staging params
params:
env: staging
environment: staging
server:
disableLiveReload: true
# Staging uses the same asset processing as production
# Enable minification for staging
minify:
disableJS: false
disableCSS: false
disableHTML: false
minifyOutput: true
# Staging asset processing
build:
writeStats: false
useResourceCacheWhen: "always"
buildOptions:
sourcemap: false
target: "es2015"
# Markdown rendering options
blackfriday:

View File

@ -55,10 +55,16 @@ outputFormats:
baseName: pages
isPlainText: true
# Asset processing configuration for development
build:
# Configure JavaScript build settings for ES6 modules
writeStats: true
useResourceCacheWhen: "fallback"
# Enable source maps for debugging
buildOptions:
sourcemap: "inline"
target: "es2020"
# Disable asset bundling in development
noJSConfigInAssets: false
# Asset processing configuration
assetDir: "assets"
@ -70,11 +76,22 @@ module:
- source: node_modules
target: assets/node_modules
# Ensure proper JavaScript processing in development
minify:
disableJS: true
minifyOutput: false
# Development settings
params:
env: development
env: development
environment: development
# Configure the server for development
# Specify the port for development to avoid conflicts with testing
server:
port: 1313
baseURL: 'http://localhost:1313/'
watchChanges: true
disableLiveReload: false
# Disable minification and bundling for development
minify:
disableJS: true
disableCSS: true
disableHTML: true
minifyOutput: false

View File

@ -12,21 +12,60 @@
{{ end -}}
{{ $products := .Site.Data.products }}
{{ $influxdb_urls := .Site.Data.influxdb_urls }}
<!-- Build index.js -->
{{ with resources.Get "js/main.js" }}
{{ $opts := dict
"minify" hugo.IsProduction
"sourceMap" (cond hugo.IsProduction "" "external")
"targetPath" "js/main.js"
"params" (dict "product" $product "currentVersion" $currentVersion "isServer" hugo.IsServer "products" $products "influxdb_urls" $influxdb_urls "cloudUrls" $cloudUrls)
}}
{{ with . | js.Build $opts }}
{{ if hugo.IsProduction }}
{{ with . | fingerprint }}
<script defer src="{{ .RelPermalink }}" integrity="{{ .Data.Integrity }}" crossorigin="anonymous"></script>
{{ end }}
{{ else }}
{{ $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 */}}
{{ $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" }}
{{ $opts := dict
"minify" false
"sourceMap" "inline"
"targetPath" "js/main.js"
"params" $sharedParams
}}
{{ with . | js.Build $opts }}
<script defer src="{{ .RelPermalink }}"></script>
{{ end }}
{{ end }}
{{ end }}
{{/* Load other individual JS files for debugging */}}
{{ range $file := (readDir "assets/js") }}
{{ if and (strings.HasSuffix $file.Name ".js") (ne $file.Name "main.js") }}
{{ $jsPath := printf "js/%s" $file.Name }}
{{ with resources.Get $jsPath }}
{{ $opts := dict
"minify" false
"sourceMap" "inline"
"targetPath" $jsPath
"params" $sharedParams
}}
{{ with . | js.Build $opts }}
<script defer src="{{ .RelPermalink }}"></script>
{{ end }}
{{ end }}
{{ end }}
{{ end }}
{{ else }}
{{/* Non-development environment: Bundle everything */}}
{{ with resources.Get "js/main.js" }}
{{ $opts := dict
"minify" hugo.IsProduction
"sourceMap" (cond hugo.IsProduction "" "external")
"targetPath" "js/main.js"
"params" (dict "product" $product "currentVersion" $currentVersion "isServer" hugo.IsServer "products" $products "influxdb_urls" $influxdb_urls "cloudUrls" $cloudUrls)
}}
{{ with . | js.Build $opts }}
{{ if hugo.IsProduction }}
{{ with . | fingerprint }}
<script defer src="{{ .RelPermalink }}" integrity="{{ .Data.Integrity }}" crossorigin="anonymous"></script>
{{ end }}
{{ else }}
<script defer src="{{ .RelPermalink }}"></script>
{{ end }}
{{ end }}
{{ end }}
{{ end }}