Content Type and Fields programmatically I make a module in Drupal 8 who create a new content type programmatically.
Module name : Annonce

In config/install I add this file:

node.type.annonce_type.yml

type: annonce_type
name: 'Ajouter une annonce'
description: 'Formulaire pour ajouter une annonce'
help: ''
new_revision: false
display_submitted: true
preview_mode: 0
status: true
langcode: fr


All is good, my new content type is create in backoffice.
But now I want to add some fields programmatically, and I don't find a core module who are doing that.
I answered pretty much the same once already I think, but I can't find that answer anymore.

You add fields and their widget and formatter configuration in the same way. By adding all the relevant config entities.

You can find almost all of them by exporting configuration into the staging folder and then search for files that contain "announce_type" in the file name. That gives you the fields, the form and view displays configurations.

Then you also need the field storages. These are shared across bundles, so they don't have the node type in them (unless you prefixes your fields with your node type/module, which is a good idea if you want to make them part of your module).

Put all those fields in config/install and you're done.