Sourcemaps aren't working in dev mode

Created on 28 August 2023, about 1 year ago
Updated 22 April 2024, 7 months ago

Problem/Motivation

When I first set this up, it was injecting inline styles. I'd like to see the css included as the file, so I can tell where to make changes.

I tried this theme, which has it's own method of integrating with vite: https://github.com/almunnings/drupal-vite-bootstrap

With that set up, the css url is pointing to a lando url that proxies vite dev.

I found that the vite module is converting js libraries to css:

unset($library['css'][$type][$path]);
$options['type'] = 'external';
$attributes = $options['attributes'] ?? [];
$attributes['type'] = 'module';
$options['attributes'] = $attributes;
$newPath = $devServerBaseUrl . '/' . $path;
$library['js'][$newPath] = $options;

Is this a mistake? Why isn't it using $library['css'] for updating CSS files?

If I replace that with:

          unset($library['css'][$type][$path]);
          $newPath = $devServerBaseUrl . '/' . $path;
          $library['css'][$type][$newPath] = [];

Now it loads the css as a stylesheet.

I currently have main.css included via index.html. I have been trying different combinations with rollupOptions input, and including the css in main.js (I'm not sure how it should be set for Drupal theming).

With css.Sourcemap = true, and main.css imported in main.js, and not using the fix above, it still adds the css inline, but the sourcemap lets you see it in the inspector. Is this a commonly used JS convention or something?

πŸ’¬ Support request
Status

Closed: works as designed

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

Comments & Activities

Production build 0.71.5 2024