Make WordPress Core

Opened 6 years ago

Closed 6 years ago

#45214 closed enhancement (fixed)

Add a build npm script

Reported by: andrewtaylor's profile andrew.taylor Owned by: pento's profile pento
Milestone: 5.0 Priority: normal
Severity: normal Version: 5.1
Component: Build/Test Tools Keywords: has-patch fixed-5.0
Focuses: Cc:

Description

Currently, in order to run the build step for WordPress core files, Grunt must be installed globally. This requirement can be removed by making use of npm scripts to run
grunt build as npm scripts adds executables to the PATH. In addition to not requiring Grunt to be installed globally, this has the added benefit of ensuring the version of Grunt run is consistent as the version in node_modules is managed with npm whereas users likely have a different version installed globally.

Attachments (1)

45214.patch (298 bytes) - added by andrew.taylor 6 years ago.
Patch file to add a "build" npm script

Download all attachments as: .zip

Change History (9)

@andrew.taylor
6 years ago

Patch file to add a "build" npm script

#1 @andrew.taylor
6 years ago

The attached patch file adds a build npm script that maps to grunt. This allows npm run build to be used to build WordPress core files without requiring Grunt to be installed globally, assuming npm install has been run.

#2 @andrew.taylor
6 years ago

Should other Grunt tasks besides the default task be added as npm scripts as well?

#3 @pento
6 years ago

  • Milestone changed from Awaiting Review to 5.0
  • Owner set to pento
  • Status changed from new to assigned

Thank you for the suggestion, @andrew.taylor!

This is a useful shortcut to using Grunt, I don't think we need to shortcuts for every grunt task now, as npm defaults to passing any extra parameters to the script.

With that in mind, I'm going to tweak your patch slightly to rename it to grunt, so npm run grunt ... is effectively the same as running grunt ....

#4 @pento
6 years ago

In 43836:

Build Tools: Add an npm script shortcut to run grunt.

Rather than needing to install grunt globally, this allows running grunt from node_modules, instead.

npm run grunt ... is effectively the equivalent of running grunt ....

Props andrew.taylor.
See #45214.

#5 @pento
6 years ago

  • Keywords fixed-5.0 added

#6 @andrew.taylor
6 years ago

Thank you @pento for getting this in. Is there anything I can do to help update documentation? There seem to be quite a few handbook pages referencing Grunt. Testing a patch specifically comes to mind as something new contributors will be looking at that suggests installing Grunt globally. The goal here is to make that unnecessary.

Last edited 6 years ago by andrew.taylor (previous) (diff)

#7 @atimmer
6 years ago

In 44176:

Build Tools: Add an npm script shortcut to run grunt.

Rather than needing to install grunt globally, this allows running grunt from node_modules, instead.

npm run grunt ... is effectively the equivalent of running grunt ....

Props andrew.taylor, pento.
Merges [43836] to trunk.
See #45214.

#8 @SergeyBiryukov
6 years ago

  • Resolution set to fixed
  • Status changed from assigned to closed
Note: See TracTickets for help on using tickets.