swc_css_minifier/compressor/
import.rs

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
use swc_css_ast::*;

use super::Compressor;

impl Compressor {
    pub(super) fn compress_import_href(&mut self, import_href: &mut ImportHref) {
        if let ImportHref::Url(Url {
            value: Some(value),
            modifiers,
            span,
            ..
        }) = import_href
        {
            if let Some(modifiers) = modifiers {
                if !modifiers.is_empty() {
                    return;
                }
            }

            let new_value = match &mut **value {
                UrlValue::Str(Str { value, .. }) => value,
                UrlValue::Raw(UrlValueRaw { value, .. }) => value,
            };

            *import_href = ImportHref::Str(Str {
                span: *span,
                value: new_value.clone(),
                raw: None,
            });
        }
    }
}