elementor/Gruntfile.js
Netanel Baba e753160e7c
Internal: Remove unused grunt plugins and silence webpack perf hints (#35193)
## Summary
- Remove 6 unused grunt devDependencies (`grunt-release`, `grunt-shell`,
`grunt-text-replace`, `grunt-bumpup`, `grunt-contrib-qunit`,
`grunt-wp-readme-to-markdown-with-extra`) that were never invoked by any
npm script, CI workflow, or registered grunt task
- Remove their corresponding `grunt.initConfig` entries from
`Gruntfile.js`
- Delete orphaned config files: `.grunt-config/release.js`,
`.grunt-config/replace.js`, `.grunt-config/shell.js`
- Add `performance: { hints: false }` to the webpack packages config to
silence irrelevant bundle-size warnings — these are WordPress-enqueued
assets so the 244 KiB browser threshold doesn't apply
- Side effect: vulnerability count drops from 76 → 66 (grunt-release
pulled in shelljs@0.7.x which had 10 known CVEs)

## Test plan
- [x] `npm run build` — exits 0 with **zero warnings** (previously had
shelljs circular dep noise + 3 webpack perf warnings)
- [x] `npm run test` — 365/367 suites pass (2 pre-existing skips, no
regressions)
- [x] `npm run lint` — exits 0, no new warnings introduced

## Jira
No ticket

Made with [Cursor](https://cursor.com)
<!--start_gitstream_placeholder-->
###  PR Description
Purpose: Remove unused Grunt build task configurations and disable
webpack performance warnings to reduce build noise and simplify tooling
setup.

Main changes:
- Removed 6 unused grunt plugin dependencies (grunt-bumpup,
grunt-contrib-qunit, grunt-release, grunt-shell, grunt-text-replace,
grunt-wp-readme-to-markdown-with-extra) from package.json
- Deleted release.js configuration file and removed corresponding task
registrations (replace, shell, release) from Gruntfile.js
- Disabled webpack performance hints in packages build configuration to
suppress bundle size warnings

_Generated by LinearB AI and added by gitStream._
<sub>AI-generated content may contain inaccuracies. Please verify before
using.
💡 **Tip:** You can customize your AI Description using **Guidelines**
[Learn
how](https://docs.gitstream.cm/automation-actions/#describe-changes)</sub>
<!--end_gitstream_placeholder-->

Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
Co-authored-by: ElementorBot <48412871+elementorbot@users.noreply.github.com>
2026-03-18 16:02:54 +02:00

137 lines
3.6 KiB
JavaScript

module.exports = function( grunt ) {
'use strict';
const fs = require( 'fs' ),
pkgInfo = grunt.file.readJSON( 'package.json' ),
WidgetsCss = require( './.grunt-config/widgets-css' ),
Eicons = require( './.grunt-config/eicons' );
const widgetsCss = new WidgetsCss( 'production' ),
eicons = new Eicons();
grunt.loadNpmTasks( 'grunt-concurrent' );
require( 'load-grunt-tasks' )( grunt );
// Project configuration
grunt.initConfig( {
pkg: pkgInfo,
banner: '/*! <%= pkg.name %> - v<%= pkg.version %> - ' +
'<%= grunt.template.today("dd-mm-yyyy") %> */',
checktextdomain: require( './.grunt-config/checktextdomain' ),
usebanner: require( './.grunt-config/usebanner' ),
sass: require( './.grunt-config/sass' ),
postcss: require( './.grunt-config/postcss' ),
watch: require( './.grunt-config/watch' ),
copy: require( './.grunt-config/copy' ),
clean: require( './.grunt-config/clean' ),
webpack: require( './.grunt-config/webpack' ),
karma: require( './.grunt-config/karma' ),
} );
grunt.registerTask( 'create_widgets_temp_scss_files', () => widgetsCss.createWidgetsTempScssFiles() );
grunt.registerTask( 'remove_widgets_unused_style_files', () => widgetsCss.removeWidgetsUnusedStyleFiles() );
grunt.registerTask( 'create_eicons_frontend_js_file', () => eicons.createFrontendIconsFile() );
grunt.registerTask( 'i18n', [
'checktextdomain',
] );
grunt.registerTask( 'scripts', ( isDevMode = false ) => {
const tasksToRun = [];
tasksToRun.push( isDevMode ? 'webpack:development' : 'webpack:production' );
tasksToRun.push( 'create_eicons_frontend_js_file' );
if ( ! isDevMode ) {
tasksToRun.push( 'webpack:developmentNoWatch' );
}
concurrent( tasksToRun );
} );
grunt.registerTask( 'watch_scripts', () => {
grunt.task.run( 'webpack:development' );
} );
grunt.registerTask( 'watch_scripts:production', () => {
grunt.task.run( 'webpack:productionWatch' );
} );
grunt.registerTask( 'styles', ( isDevMode = false ) => {
if ( ! isDevMode ) {
grunt.task.run( 'create_widgets_temp_scss_files' );
}
grunt.task.run( 'sass' );
if ( ! isDevMode ) {
grunt.task.run( 'postcss' );
grunt.task.run( 'css_templates' );
grunt.task.run( 'remove_widgets_unused_style_files' );
}
} );
grunt.registerTask( 'watch_styles', () => {
concurrent( [ 'styles', 'watch:styles' ] );
} );
grunt.registerTask( 'css_templates', () => {
grunt.task.run( 'css_templates_proxy:templates' );
const responsiveWidgetsList = widgetsCss.getResponsiveWidgetsList();
grunt.config( 'sass.dist', {
files: [ {
expand: true,
cwd: 'assets/dev/scss/direction',
src: [
'frontend.scss',
'frontend-rtl.scss',
...responsiveWidgetsList,
],
dest: 'assets/css/templates',
ext: '.css',
} ],
} );
grunt.task.run( 'sass' );
grunt.config( 'postcss.minify.files.0.src', [
'assets/css/templates/*.css',
'!assets/css/templates/*.min.css',
] );
grunt.task.run( 'postcss:minify' );
grunt.task.run( 'css_templates_proxy:values' );
} );
// Writing the proxy file as a grunt task, in order to fit in with the tasks queue
grunt.registerTask( 'css_templates_proxy', ( mode ) => {
fs.writeFileSync( 'assets/dev/scss/frontend/breakpoints/proxy.scss', '@import "' + mode + '";' );
} );
grunt.registerTask( 'build', () => {
concurrent( [ 'i18n', 'scripts', 'styles', 'usebanner' ] );
grunt.task.run( 'clean' );
grunt.task.run( 'copy' );
} );
grunt.registerTask( 'test', [
'karma:unit',
] );
const concurrent = ( tasks ) => {
grunt.config.set( 'concurrent.onDemand', {
tasks,
options: { logConcurrentOutput: true },
} );
grunt.task.run( 'concurrent:onDemand' );
};
};