Allow enabling vite for all components and libraries in theme/module

Created on 28 December 2023, 6 months ago
Updated 21 May 2024, about 1 month ago

I was using v1.0.0 and the patch for SDC in https://www.drupal.org/project/vite/issues/3349323 ✨ SDC integration Fixed

With this setup, I didn't need to edit *.component.yml to enable vite, it was working with the css files in the component dir.

I used glob to parse the css files in components and export to the themes /dist.

The patch was changing the source path of theme components to the /dist dir.

Can we get a global setting to enable vite for all theme components?

✨ Feature request
Status

RTBC

Version

1.0

Component

Code

Created by

πŸ‡ΊπŸ‡ΈUnited States mortona2k Seattle

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Merge Requests

Comments & Activities

  • Issue created by @mortona2k
  • Status changed to Needs review 6 months ago
  • πŸ‡ΊπŸ‡ΈUnited States mortona2k Seattle

    I got this working with a simple change.

    In settings.php, configure vite to enable your theme:

    $settings['vite'] = [
      'overrides' => [
        'vite_theme' => [
          'enabled' => true
        ]
      ]
    ];

    In Vite.php, change line 47:
    - if ($extension === 'sdc' && isset($library['vite']) && $library['vite'] === TRUE) {
    + if ($extension === 'sdc') {

    AssetLibrary::shouldBeManagedByVite() already has the check for vite enabled in the library, so it is unnecessary here.

  • Merge request !7Skip check for sdc vite enabled β†’ (Closed) created by wotnak
  • First commit to issue fork.
  • Status changed to Needs work 5 months ago
  • πŸ‡΅πŸ‡±Poland wotnak

    Change looks good, will merge it.

    But first, I think it would be also good to provide an option to enable vite in all components/libraries of the theme/module right in the theme/module, so that vite configuration is contained in the theme/module it applies to and changes to settings.php aren't required for the theme/module to work.

    Thinking of adding vite section to the .info.yml file that will allow enabling vite in all sdc components and/or all libraries defined in .libraries.yml, something like:

    name: My theme
    [...]
    vite:
      enableInAllComponents: true
      enableInAllLibraries: true
    [...]
    
  • Pipeline finished with Success
    3 months ago
    Total: 140s
    #126694
  • πŸ‡ΊπŸ‡ΈUnited States mortona2k Seattle

    I rebased the branch on the latest dev commit.

    @wotnak we already have override module/theme/library options in settings.php. I'm assuming that should take precedence in case you want to override something from contrib.

  • Pipeline finished with Failed
    3 months ago
    Total: 171s
    #132152
  • Status changed to RTBC about 1 month ago
  • πŸ‡΅πŸ‡±Poland wotnak

    Marking as RTBC. Changes from https://git.drupalcode.org/project/vite/-/merge_requests/12 worked for us in internal and client projects without any problems.

  • Pipeline finished with Skipped
    about 1 month ago
    #178222
    • wotnak β†’ committed 4bafb169 on 1.x
      Issue #3411117 by mortona2k, wotnak: Allow enabling vite for all...
Production build 0.69.0 2024