Skip to content

Commit 3aba398

Browse files
committed
[TASK] Introduce grunt command for debugging
1 parent a966dcc commit 3aba398

File tree

6 files changed

+74
-3
lines changed

6 files changed

+74
-3
lines changed

.ddev/commands/web/npm-build

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
#!/bin/bash
2+
3+
cd packages/typo3-docs-theme
4+
npm run build

.ddev/commands/web/npm-ci

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
#!/bin/bash
2+
3+
cd packages/typo3-docs-theme
4+
npm ci

.ddev/commands/web/npm-debug

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
#!/bin/bash
2+
3+
cd packages/typo3-docs-theme
4+
npm run debug

Documentation/Developer/ThemeCustomization.rst

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,39 @@ To build the public assets execute the following commands:
4040
npm ci
4141
npm run build
4242
43+
Or use the custom ddev commands:
44+
45+
.. code-block:: shell
46+
47+
ddev npm-ci
48+
ddev npm-build
49+
50+
51+
Debug assets
52+
============
53+
54+
You can build the assets for debugging with the following commands:
55+
56+
.. code-block:: shell
57+
58+
ddev ssh
59+
cd packages/typo3-docs-theme
60+
npm ci
61+
npm run debug
62+
63+
Or use the custom ddev commands:
64+
65+
.. code-block:: shell
66+
67+
ddev npm-ci
68+
ddev npm-debug
69+
70+
The generated assets are copied directly into :file:`Documentation-GENERATED-temp/_resources`
71+
and source maps are not removed. Upon inspection in the browsers web developer
72+
tools you can therefore see in which source scss file certain styles were
73+
defined. Before committing you must run :shell:`npm run build` so that you can
74+
commit the generated asset files into the theme.
75+
4376

4477
.. _Bootstrap: https://getbootstrap.com/
4578
.. _phpDocumentor/guides: https://github.com/phpDocumentor/guides

packages/typo3-docs-theme/Gruntfile.js

Lines changed: 27 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,8 @@ module.exports = function (grunt) {
3030
pkg: grunt.file.readJSON('package.json'),
3131
paths: {
3232
source: 'assets/',
33-
output: 'resources/public/'
33+
output: 'resources/public/',
34+
debugDestination: '../../Documentation-GENERATED-temp/_resources/',
3435
},
3536

3637
// copy
@@ -76,7 +77,18 @@ module.exports = function (grunt) {
7677
dest: '<%= paths.output %>js/bootstrap.min.js'
7778
}
7879
]
79-
}
80+
},
81+
82+
debug: {
83+
files: [
84+
{
85+
expand: true,
86+
cwd: '<%= paths.source %>', // Adjust the source directory
87+
src: ['**/*'],
88+
dest: '<%= paths.debugDestination %>', // Use the debug destination variable
89+
},
90+
],
91+
},
8092
},
8193

8294
// stylelint
@@ -102,6 +114,18 @@ module.exports = function (grunt) {
102114
'<%= paths.output %>css/theme.css': '<%= paths.source %>sass/theme.scss',
103115
'<%= paths.output %>css/webfonts.css': '<%= paths.source %>sass/webfonts.scss'
104116
}
117+
},
118+
119+
debug: {
120+
options: {
121+
sourceMap: true, // Enable sourcemaps for debugging
122+
},
123+
files: {
124+
'<%= paths.debugDestination %>css/codeblock.css': '<%= paths.source %>sass/codeblock.scss',
125+
'<%= paths.debugDestination %>css/fontawesome.css': '<%= paths.source %>sass/fontawesome.scss',
126+
'<%= paths.debugDestination %>css/theme.css': '<%= paths.source %>sass/theme.scss',
127+
'<%= paths.debugDestination %>css/webfonts.css': '<%= paths.source %>sass/webfonts.scss'
128+
}
105129
}
106130
},
107131

@@ -174,4 +198,5 @@ module.exports = function (grunt) {
174198
grunt.registerTask('default', ['clean', 'update', 'stylelint', 'sass', 'js', 'removesourcemap']);
175199
grunt.registerTask('build', ['default']);
176200
grunt.registerTask('render', ['clean:build']);
201+
grunt.registerTask('debug', ['clean', 'update', 'stylelint', 'sass:debug', 'js', 'copy:debug', 'removesourcemap']);
177202
};

packages/typo3-docs-theme/package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,8 @@
2121
"stylelint": "^15.11.0"
2222
},
2323
"scripts": {
24-
"build": "grunt build"
24+
"build": "grunt build",
25+
"debug": "grunt debug"
2526
},
2627
"engines": {
2728
"node": ">=18.15.0 <21.0.0"

0 commit comments

Comments
 (0)