Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 21 additions & 1 deletion Gruntfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -279,6 +279,11 @@ module.exports = function( grunt) {
command: function ( input, output ) {
return `npx tailwindcss -i ${input} -o ${output}`;
}
},
tailwind_minify: {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

use existing uglify grunt tasks for minification.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The tailwind_minify shell command is defined at Gruntfile.js:283.
It plays a critical role in the asset optimization workflow for the project’s CSS files.


⚙️ Purpose

The command’s main function is to minify CSS files generated by Tailwind using the built-in --minify flag.
It ensures all Tailwind-processed CSS files are optimized before being deployed.


🔍 Why It’s Needed

1. Different Functional Scope

  • uglify task → Handles JavaScript minification only.

  • tailwind_minify task → Handles CSS minification using Tailwind CLI.

Removing tailwind_minify would leave CSS unminified, negatively affecting bundle size and performance.

command: function ( input, output ) {
return `npx tailwindcss -i ${input} -o ${output} --minify`;
}
}
}
});
Expand All @@ -305,7 +310,7 @@ module.exports = function( grunt) {
grunt.registerTask( 'readme', [ 'wp_readme_to_markdown' ] );

// build stuff
grunt.registerTask( 'release', [ 'less', 'concat', 'uglify', 'i18n', 'readme', 'tailwind' ] );
grunt.registerTask( 'release', [ 'less', 'concat', 'uglify', 'i18n', 'readme', 'tailwind', 'tailwind-minify' ] );
grunt.registerTask( 'zip', [ 'clean', 'copy', 'compress' ] );

grunt.event.on('watch', function(action, filepath, target) {
Expand All @@ -331,4 +336,19 @@ module.exports = function( grunt) {

done();
});

grunt.registerTask('tailwind-minify', function() {
const cssFiles = [
{ input: 'assets/css/forms-list.css', output: 'assets/css/forms-list.min.css' },
{ input: 'assets/css/frontend-subscriptions.css', output: 'assets/css/frontend-subscriptions.min.css' },
{ input: 'assets/css/ai-form-builder.css', output: 'assets/css/ai-form-builder.min.css' },
{ input: 'assets/css/admin/subscriptions.css', output: 'assets/css/admin/subscriptions.min.css' }
];

cssFiles.forEach(file => {
if (grunt.file.exists(file.input)) {
grunt.task.run(`shell:tailwind_minify:${file.input}:${file.output}`);
}
});
});
};
2 changes: 1 addition & 1 deletion assets/css/admin/subscriptions.min.css

Large diffs are not rendered by default.

Loading
Loading