Skip to content

Commit aac841a

Browse files
committed
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.
1 parent 5c419c1 commit aac841a

File tree

10 files changed

+210
-17809
lines changed

10 files changed

+210
-17809
lines changed

.circleci/config.yml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
version: 2
1+
version: 2.1
22
jobs:
33
build:
44
docker:
@@ -68,7 +68,6 @@ jobs:
6868
when: on_success
6969

7070
workflows:
71-
version: 2
7271
build:
7372
jobs:
7473
- build

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ node_modules
2121
test-results.xml
2222
/influxdb3cli-build-scripts/content
2323
.vscode/*
24+
!.vscode/launch.json
2425
.idea
2526
**/config.toml
2627
package-lock.json

.vscode/launch.json

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
{
2+
"version": "0.2.0",
3+
"configurations": [
4+
{
5+
"name": "Debug Docs (console-based)",
6+
"type": "chrome",
7+
"request": "launch",
8+
"url": "http://localhost:1313",
9+
"webRoot": "${workspaceFolder}",
10+
"skipFiles": [
11+
"<node_internals>/**"
12+
],
13+
"sourceMaps": false,
14+
"trace": true,
15+
"smartStep": false
16+
}
17+
]
18+
}

assets/js/utils/debug-helpers.js

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
/**
2+
* Helper functions for debugging without source maps
3+
* Example usage:
4+
* In your code, you can use these functions like this:
5+
* ```javascript
6+
* import { debugLog, debugBreak, debugInspect } from './debug-helpers.js';
7+
*
8+
* const data = debugInspect(someData, 'Data');
9+
* debugLog('Processing data', 'myFunction');
10+
*
11+
* function processData() {
12+
* // Add a breakpoint that works with DevTools
13+
* debugBreak();
14+
*
15+
* // Your existing code...
16+
* }
17+
* ```
18+
*
19+
* @fileoverview DEVELOPMENT USE ONLY - Functions should not be committed to production
20+
*/
21+
22+
/* eslint-disable no-debugger */
23+
/* eslint-disable-next-line */
24+
// NOTE: These functions are detected by ESLint rules to prevent committing debug code
25+
26+
export function debugLog(message, context = '') {
27+
const contextStr = context ? `[${context}]` : '';
28+
console.log(`DEBUG${contextStr}: ${message}`);
29+
}
30+
31+
export function debugBreak() {
32+
debugger;
33+
}
34+
35+
export function debugInspect(value, label = 'Inspect') {
36+
console.log(`DEBUG[${label}]:`, value);
37+
return value;
38+
}

config/production/config.yml

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,25 @@ minify:
1616
# Production asset processing
1717
build:
1818
writeStats: false
19-
useResourceCacheWhen: "always"
19+
useResourceCacheWhen: "fallback"
2020
buildOptions:
2121
sourcemap: false
2222
target: "es2015"
2323

24+
# Asset processing configuration
25+
assetDir: "assets"
26+
27+
# Mount assets for production
28+
module:
29+
mounts:
30+
- source: assets
31+
target: assets
32+
- source: node_modules
33+
target: assets/node_modules
34+
2435
# Disable development server settings
25-
server: {}
36+
server: {}
37+
38+
# Suppress the warning mentioned in the error
39+
ignoreLogs:
40+
- 'warning-goldmark-raw-html'

config/testing/config.yml

Lines changed: 34 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -15,29 +15,6 @@ preserveTaxonomyNames: true
1515
# Generate a robots.txt
1616
enableRobotsTXT: true
1717

18-
# Override settings for testing
19-
buildFuture: true
20-
21-
# Configure what content is built in testing env
22-
params:
23-
env: testing
24-
environment: testing
25-
buildTestContent: true
26-
27-
# Server configuration for testing
28-
server:
29-
port: 1315
30-
baseURL: 'http://localhost:1315/'
31-
watchChanges: true
32-
disableLiveReload: false
33-
34-
# Keep your shared content exclusions
35-
ignoreFiles:
36-
- "content/shared/.*"
37-
38-
# Ignore specific warning logs
39-
ignoreLogs:
40-
- warning-goldmark-raw-html
4118

4219
# Markdown rendering options
4320
blackfriday:
@@ -55,7 +32,6 @@ taxonomies:
5532
influxdb3/enterprise/tag: influxdb3/enterprise/tags
5633
flux/v0/tag: flux/v0/tags
5734

58-
# Markup configuration
5935
markup:
6036
goldmark:
6137
renderer:
@@ -66,7 +42,6 @@ markup:
6642
attribute:
6743
block: true
6844

69-
# Privacy settings
7045
privacy:
7146
googleAnalytics:
7247
anonymizeIP: false
@@ -77,7 +52,6 @@ privacy:
7752
disable: false
7853
privacyEnhanced: true
7954

80-
# Output formats
8155
outputFormats:
8256
json:
8357
mediaType: application/json
@@ -86,26 +60,47 @@ outputFormats:
8660

8761
# Asset processing for testing (disable minification)
8862
build:
89-
writeStats: true
63+
writeStats: false
9064
useResourceCacheWhen: "fallback"
91-
buildOptions:
92-
sourcemap: "inline"
93-
target: "es2020"
94-
95-
# Disable minification for testing
96-
minify:
97-
disableJS: true
98-
disableCSS: true
99-
disableHTML: true
100-
minifyOutput: false
65+
noJSConfigInAssets: false
10166

10267
# Asset processing configuration
10368
assetDir: "assets"
10469

105-
# Module mounts
10670
module:
10771
mounts:
10872
- source: assets
10973
target: assets
11074
- source: node_modules
111-
target: assets/node_modules
75+
target: assets/node_modules
76+
77+
# Override settings for testing
78+
buildFuture: true
79+
80+
# Configure what content is built in testing env
81+
params:
82+
env: testing
83+
environment: testing
84+
buildTestContent: true
85+
86+
# Configure the server for testing
87+
server:
88+
port: 1315
89+
baseURL: 'http://localhost:1315/'
90+
watchChanges: true
91+
disableLiveReload: false
92+
93+
# Keep your shared content exclusions
94+
ignoreFiles:
95+
- "content/shared/.*"
96+
97+
# Ignore specific warning logs
98+
ignoreLogs:
99+
- warning-goldmark-raw-html
100+
101+
# Disable minification for testing
102+
minify:
103+
disableJS: true
104+
disableCSS: true
105+
disableHTML: true
106+
minifyOutput: false

eslint.config.js

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,33 @@ export default [
106106
files: ['assets/js/**/*.js'],
107107
rules: {
108108
// Rules specific to JavaScript in Hugo assets
109+
// Prevent imports from debug-helpers.js
110+
'no-restricted-imports': [
111+
'error',
112+
{
113+
paths: [
114+
{
115+
name: './utils/debug-helpers.js',
116+
message:
117+
'Remove debugging functions before committing. Debug helpers should not be used in production code.',
118+
},
119+
{
120+
name: '/utils/debug-helpers.js',
121+
message:
122+
'Remove debugging functions before committing. Debug helpers should not be used in production code.',
123+
},
124+
],
125+
},
126+
],
127+
// Prevent use of debug functions in production code
128+
'no-restricted-syntax': [
129+
'error',
130+
{
131+
selector: 'CallExpression[callee.name=/^debug(Log|Break|Inspect)$/]',
132+
message:
133+
'Remove debugging functions before committing. Debug helpers should not be used in production code.',
134+
},
135+
],
109136
},
110137
},
111138
{

hugo.yml

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ privacy:
4949
youtube:
5050
disable: false
5151
privacyEnhanced: true
52+
5253
outputFormats:
5354
json:
5455
mediaType: application/json
@@ -57,13 +58,8 @@ outputFormats:
5758

5859
# Asset processing configuration for development
5960
build:
60-
writeStats: true
61+
writeStats: false
6162
useResourceCacheWhen: "fallback"
62-
# Enable source maps for debugging
63-
buildOptions:
64-
sourcemap: "inline"
65-
target: "es2020"
66-
# Disable asset bundling in development
6763
noJSConfigInAssets: false
6864

6965
# Asset processing configuration
@@ -82,14 +78,17 @@ params:
8278
environment: development
8379

8480
# Configure the server for development
85-
# Specify the port for development to avoid conflicts with testing
8681
server:
8782
port: 1313
8883
baseURL: 'http://localhost:1313/'
8984
watchChanges: true
9085
disableLiveReload: false
9186

92-
# Disable minification and bundling for development
87+
# Ignore specific warning logs
88+
ignoreLogs:
89+
- warning-goldmark-raw-html
90+
91+
# Disable minification for development
9392
minify:
9493
disableJS: true
9594
disableCSS: true

0 commit comments

Comments
 (0)