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. - Add support for debugging in VS Code without using source maps. Adds a debug helpers module for developers to use in IDE debugging and interact with the browser console. This is a workaround for lack of good source map support with js.Build and the Hugo asset pipeline. Background: Hugo and js.Build don't have good support for external source maps. Internal source mapping is also unreliable; the base64 in the source map reference for some files is too long for the browser console to keep on 1 line--remaining characters are printed on the next line, resulting in a syntax error.pull/6079/head
parent
5c419c18bb
commit
aac841a749
|
@ -1,4 +1,4 @@
|
||||||
version: 2
|
version: 2.1
|
||||||
jobs:
|
jobs:
|
||||||
build:
|
build:
|
||||||
docker:
|
docker:
|
||||||
|
@ -68,7 +68,6 @@ jobs:
|
||||||
when: on_success
|
when: on_success
|
||||||
|
|
||||||
workflows:
|
workflows:
|
||||||
version: 2
|
|
||||||
build:
|
build:
|
||||||
jobs:
|
jobs:
|
||||||
- build
|
- build
|
||||||
|
|
|
@ -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,18 @@
|
||||||
|
{
|
||||||
|
"version": "0.2.0",
|
||||||
|
"configurations": [
|
||||||
|
{
|
||||||
|
"name": "Debug Docs (console-based)",
|
||||||
|
"type": "chrome",
|
||||||
|
"request": "launch",
|
||||||
|
"url": "http://localhost:1313",
|
||||||
|
"webRoot": "${workspaceFolder}",
|
||||||
|
"skipFiles": [
|
||||||
|
"<node_internals>/**"
|
||||||
|
],
|
||||||
|
"sourceMaps": false,
|
||||||
|
"trace": true,
|
||||||
|
"smartStep": false
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
|
@ -0,0 +1,38 @@
|
||||||
|
/**
|
||||||
|
* Helper functions for debugging without source maps
|
||||||
|
* Example usage:
|
||||||
|
* In your code, you can use these functions like this:
|
||||||
|
* ```javascript
|
||||||
|
* import { debugLog, debugBreak, debugInspect } from './debug-helpers.js';
|
||||||
|
*
|
||||||
|
* const data = debugInspect(someData, 'Data');
|
||||||
|
* debugLog('Processing data', 'myFunction');
|
||||||
|
*
|
||||||
|
* function processData() {
|
||||||
|
* // Add a breakpoint that works with DevTools
|
||||||
|
* debugBreak();
|
||||||
|
*
|
||||||
|
* // Your existing code...
|
||||||
|
* }
|
||||||
|
* ```
|
||||||
|
*
|
||||||
|
* @fileoverview DEVELOPMENT USE ONLY - Functions should not be committed to production
|
||||||
|
*/
|
||||||
|
|
||||||
|
/* eslint-disable no-debugger */
|
||||||
|
/* eslint-disable-next-line */
|
||||||
|
// NOTE: These functions are detected by ESLint rules to prevent committing debug code
|
||||||
|
|
||||||
|
export function debugLog(message, context = '') {
|
||||||
|
const contextStr = context ? `[${context}]` : '';
|
||||||
|
console.log(`DEBUG${contextStr}: ${message}`);
|
||||||
|
}
|
||||||
|
|
||||||
|
export function debugBreak() {
|
||||||
|
debugger;
|
||||||
|
}
|
||||||
|
|
||||||
|
export function debugInspect(value, label = 'Inspect') {
|
||||||
|
console.log(`DEBUG[${label}]:`, value);
|
||||||
|
return value;
|
||||||
|
}
|
|
@ -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'
|
|
@ -15,29 +15,6 @@ preserveTaxonomyNames: true
|
||||||
# Generate a robots.txt
|
# Generate a robots.txt
|
||||||
enableRobotsTXT: true
|
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
|
|
||||||
|
|
||||||
# Markdown rendering options
|
# Markdown rendering options
|
||||||
blackfriday:
|
blackfriday:
|
||||||
|
@ -55,7 +32,6 @@ taxonomies:
|
||||||
influxdb3/enterprise/tag: influxdb3/enterprise/tags
|
influxdb3/enterprise/tag: influxdb3/enterprise/tags
|
||||||
flux/v0/tag: flux/v0/tags
|
flux/v0/tag: flux/v0/tags
|
||||||
|
|
||||||
# Markup configuration
|
|
||||||
markup:
|
markup:
|
||||||
goldmark:
|
goldmark:
|
||||||
renderer:
|
renderer:
|
||||||
|
@ -66,7 +42,6 @@ markup:
|
||||||
attribute:
|
attribute:
|
||||||
block: true
|
block: true
|
||||||
|
|
||||||
# Privacy settings
|
|
||||||
privacy:
|
privacy:
|
||||||
googleAnalytics:
|
googleAnalytics:
|
||||||
anonymizeIP: false
|
anonymizeIP: false
|
||||||
|
@ -77,7 +52,6 @@ privacy:
|
||||||
disable: false
|
disable: false
|
||||||
privacyEnhanced: true
|
privacyEnhanced: true
|
||||||
|
|
||||||
# Output formats
|
|
||||||
outputFormats:
|
outputFormats:
|
||||||
json:
|
json:
|
||||||
mediaType: application/json
|
mediaType: application/json
|
||||||
|
@ -86,11 +60,43 @@ outputFormats:
|
||||||
|
|
||||||
# Asset processing for testing (disable minification)
|
# Asset processing for testing (disable minification)
|
||||||
build:
|
build:
|
||||||
writeStats: true
|
writeStats: false
|
||||||
useResourceCacheWhen: "fallback"
|
useResourceCacheWhen: "fallback"
|
||||||
buildOptions:
|
noJSConfigInAssets: false
|
||||||
sourcemap: "inline"
|
|
||||||
target: "es2020"
|
# Asset processing configuration
|
||||||
|
assetDir: "assets"
|
||||||
|
|
||||||
|
module:
|
||||||
|
mounts:
|
||||||
|
- source: assets
|
||||||
|
target: assets
|
||||||
|
- source: node_modules
|
||||||
|
target: assets/node_modules
|
||||||
|
|
||||||
|
# Override settings for testing
|
||||||
|
buildFuture: true
|
||||||
|
|
||||||
|
# Configure what content is built in testing env
|
||||||
|
params:
|
||||||
|
env: testing
|
||||||
|
environment: testing
|
||||||
|
buildTestContent: true
|
||||||
|
|
||||||
|
# Configure the server 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
|
||||||
|
|
||||||
# Disable minification for testing
|
# Disable minification for testing
|
||||||
minify:
|
minify:
|
||||||
|
@ -98,14 +104,3 @@ minify:
|
||||||
disableCSS: true
|
disableCSS: true
|
||||||
disableHTML: true
|
disableHTML: true
|
||||||
minifyOutput: false
|
minifyOutput: false
|
||||||
|
|
||||||
# Asset processing configuration
|
|
||||||
assetDir: "assets"
|
|
||||||
|
|
||||||
# Module mounts
|
|
||||||
module:
|
|
||||||
mounts:
|
|
||||||
- source: assets
|
|
||||||
target: assets
|
|
||||||
- source: node_modules
|
|
||||||
target: assets/node_modules
|
|
|
@ -106,6 +106,33 @@ export default [
|
||||||
files: ['assets/js/**/*.js'],
|
files: ['assets/js/**/*.js'],
|
||||||
rules: {
|
rules: {
|
||||||
// Rules specific to JavaScript in Hugo assets
|
// Rules specific to JavaScript in Hugo assets
|
||||||
|
// Prevent imports from debug-helpers.js
|
||||||
|
'no-restricted-imports': [
|
||||||
|
'error',
|
||||||
|
{
|
||||||
|
paths: [
|
||||||
|
{
|
||||||
|
name: './utils/debug-helpers.js',
|
||||||
|
message:
|
||||||
|
'Remove debugging functions before committing. Debug helpers should not be used in production code.',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: '/utils/debug-helpers.js',
|
||||||
|
message:
|
||||||
|
'Remove debugging functions before committing. Debug helpers should not be used in production code.',
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
],
|
||||||
|
// Prevent use of debug functions in production code
|
||||||
|
'no-restricted-syntax': [
|
||||||
|
'error',
|
||||||
|
{
|
||||||
|
selector: 'CallExpression[callee.name=/^debug(Log|Break|Inspect)$/]',
|
||||||
|
message:
|
||||||
|
'Remove debugging functions before committing. Debug helpers should not be used in production code.',
|
||||||
|
},
|
||||||
|
],
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
|
15
hugo.yml
15
hugo.yml
|
@ -49,6 +49,7 @@ privacy:
|
||||||
youtube:
|
youtube:
|
||||||
disable: false
|
disable: false
|
||||||
privacyEnhanced: true
|
privacyEnhanced: true
|
||||||
|
|
||||||
outputFormats:
|
outputFormats:
|
||||||
json:
|
json:
|
||||||
mediaType: application/json
|
mediaType: application/json
|
||||||
|
@ -57,13 +58,8 @@ outputFormats:
|
||||||
|
|
||||||
# Asset processing configuration for development
|
# Asset processing configuration for development
|
||||||
build:
|
build:
|
||||||
writeStats: true
|
writeStats: false
|
||||||
useResourceCacheWhen: "fallback"
|
useResourceCacheWhen: "fallback"
|
||||||
# Enable source maps for debugging
|
|
||||||
buildOptions:
|
|
||||||
sourcemap: "inline"
|
|
||||||
target: "es2020"
|
|
||||||
# Disable asset bundling in development
|
|
||||||
noJSConfigInAssets: false
|
noJSConfigInAssets: false
|
||||||
|
|
||||||
# Asset processing configuration
|
# Asset processing configuration
|
||||||
|
@ -82,14 +78,17 @@ params:
|
||||||
environment: development
|
environment: development
|
||||||
|
|
||||||
# Configure the server for development
|
# Configure the server for development
|
||||||
# Specify the port for development to avoid conflicts with testing
|
|
||||||
server:
|
server:
|
||||||
port: 1313
|
port: 1313
|
||||||
baseURL: 'http://localhost:1313/'
|
baseURL: 'http://localhost:1313/'
|
||||||
watchChanges: true
|
watchChanges: true
|
||||||
disableLiveReload: false
|
disableLiveReload: false
|
||||||
|
|
||||||
# Disable minification and bundling for development
|
# Ignore specific warning logs
|
||||||
|
ignoreLogs:
|
||||||
|
- warning-goldmark-raw-html
|
||||||
|
|
||||||
|
# Disable minification for development
|
||||||
minify:
|
minify:
|
||||||
disableJS: true
|
disableJS: true
|
||||||
disableCSS: true
|
disableCSS: true
|
||||||
|
|
17728
hugo_stats.json
17728
hugo_stats.json
File diff suppressed because it is too large
Load Diff
|
@ -7,7 +7,7 @@
|
||||||
{{ $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
|
"sourceMap" "external"
|
||||||
"sourceMap" "inline"
|
"sourcesContent" true
|
||||||
"targetPath" "js/main.js"
|
"targetPath" "js/main.js"
|
||||||
|
"format" "esm"
|
||||||
|
"bundle" false
|
||||||
|
"minify" false
|
||||||
|
"target" "es2017"
|
||||||
|
"write" true
|
||||||
"params" $sharedParams
|
"params" $sharedParams
|
||||||
}}
|
}}
|
||||||
{{ 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 fileExists $jsDir }}
|
||||||
|
{{ range $file := (readDir $jsDir) }}
|
||||||
{{ if and (strings.HasSuffix $file.Name ".js") (ne $file.Name "main.js") }}
|
{{ if and (strings.HasSuffix $file.Name ".js") (ne $file.Name "main.js") }}
|
||||||
{{ $jsPath := printf "js/%s" $file.Name }}
|
{{ $jsPath := printf "js/%s" $file.Name }}
|
||||||
{{ with resources.Get $jsPath }}
|
{{ $jsRes := resources.Get $jsPath }}
|
||||||
|
{{ with $jsRes }}
|
||||||
{{ $opts := dict
|
{{ $opts := dict
|
||||||
"minify" false
|
"sourceMap" ""
|
||||||
"sourceMap" "inline"
|
|
||||||
"targetPath" $jsPath
|
"targetPath" $jsPath
|
||||||
|
"format" "esm"
|
||||||
|
"bundle" false
|
||||||
|
"minify" false
|
||||||
|
"target" "es2015"
|
||||||
|
"write" true
|
||||||
"params" $sharedParams
|
"params" $sharedParams
|
||||||
}}
|
}}
|
||||||
{{ with . | js.Build $opts }}
|
{{ $out := . | js.Build $opts }}
|
||||||
<script defer src="{{ .RelPermalink }}"></script>
|
|
||||||
|
{{/* Add descriptive debug comments at the beginning of each file */}}
|
||||||
|
{{ $debugHeader := printf "// DEBUG MODE: %s\n// Original file: assets/js/%s\n\n" $file.Name $file.Name }}
|
||||||
|
{{ $modifiedContent := printf "%s%s" $debugHeader $out.Content }}
|
||||||
|
{{ $out = resources.FromString $jsPath $modifiedContent }}
|
||||||
|
|
||||||
|
<script type="module" src="{{ $out.RelPermalink }}"></script>
|
||||||
{{ 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"
|
||||||
|
"target" "es2019"
|
||||||
|
"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