Skip to content

Introduce the customScripts property to allow templates to define additional scripts in package.json#38535

Merged
ryanwelcher merged 3 commits intoWordPress:trunkfrom
ryanwelcher:try/adding-custom-scripts
Feb 7, 2022
Merged

Introduce the customScripts property to allow templates to define additional scripts in package.json#38535
ryanwelcher merged 3 commits intoWordPress:trunkfrom
ryanwelcher:try/adding-custom-scripts

Conversation

@ryanwelcher
Copy link
Copy Markdown
Contributor

Description

As referenced in #25188 (comment), this PR adds a customScripts property to templates to add additional custom scripts to the package.json. One use-case would be to add e2e tests ie. "test:e2e": "wp-scripts test-e2e".

Testing Instructions

Types of changes

New Feature

Checklist:

  • My code is tested.
  • My code follows the WordPress code style.
  • My code follows the accessibility standards.
  • I've tested my changes with keyboard and screen readers.
  • My code has proper inline documentation.
  • I've included developer documentation if appropriate.
  • I've updated all React Native files affected by any refactorings/renamings in this PR (please manually search all *.native.js files for terms that need renaming or removal).
  • I've updated related schemas if appropriate.

@ryanwelcher ryanwelcher added [Tool] Create Block /packages/create-block Developer Experience Ideas about improving block and theme developer experience labels Feb 4, 2022
@ryanwelcher ryanwelcher changed the title Introduce the customScript property to allow templates to define addtional scripts. Introduce the customScript property to allow templates to define additional scripts in package.json Feb 4, 2022
@gziolo gziolo added [Type] New API New API to be used by plugin developers or package users. Good First Review A PR that's suitable for someone looking to contribute for the first time by reviewing code labels Feb 6, 2022
@carolinan
Copy link
Copy Markdown
Contributor

carolinan commented Feb 7, 2022

Hi
Is there any chance we can use a different name than "template" and "block template" since a block template is a term already used for something else:
Adding default blocks to a template in a custom post type
A custom-name.html file inside themes or plugins that are templates for themes with support for full site editing.

Copy link
Copy Markdown
Member

@gziolo gziolo left a comment

Choose a reason for hiding this comment

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

@ryanwelcher, this is a great idea 👍🏻

I considered it earlier when working on support for wpScripts or wpEnv, but at times it felt like too much work for every template to define all default scripts. However, this is nice, because it allows to inject or override scripts. I think you can also remove some scripts by providing a falsy value for a key.

@gziolo gziolo changed the title Introduce the customScript property to allow templates to define additional scripts in package.json Introduce the customScripts property to allow templates to define additional scripts in package.json Feb 7, 2022
@ryanwelcher ryanwelcher merged commit 48da1d9 into WordPress:trunk Feb 7, 2022
@github-actions github-actions bot added this to the Gutenberg 12.6 milestone Feb 7, 2022
@bph bph added Needs Dev Note Requires a developer note for a major WordPress release cycle and removed Good First Review A PR that's suitable for someone looking to contribute for the first time by reviewing code Developer Experience Ideas about improving block and theme developer experience labels Mar 24, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Needs Dev Note Requires a developer note for a major WordPress release cycle [Tool] Create Block /packages/create-block [Type] New API New API to be used by plugin developers or package users.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants