Fix multiple copies of utility classes being loaded by the app (#28802)

* Fix multiple copies of utility classes being loaded by the app

When using SASS's at-import rule for a file containing CSS classes, the
entirity of the imported file is included into that chunk of the JS
bundle. This leads to those class definitions being duplicated multiple
times in the code loaded by the browser. That doesn't happen for mixins,
functions, or SASS variables which are evaluated at compile time.

To prevent those classes from being repeatedly defined, we need to not
import them into multiple bundles. We already load the utility classes
into the root bundle, so we just need to make sure not to import
sass/utils/_module.scss, sass/utils/_flex.scss,
sass/utils/_animations.scss, or sass/utils/_modifiers.scss into any
CSS files which are imported into individual components.

* Canonize import paths for SCSS mixins and functions

We previously imported some .scss files as `src/sass/...` and others as
`sass/...`. This was allowed becuase sass-loader's
`sassOptions.includePaths` included both `src` and `src/sass`. I've made
that more consistent now and removed the redundant include path.
Этот коммит содержится в:
Harrison Healey
2024-10-18 10:50:26 -04:00
коммит произвёл GitHub
родитель b4d8b6239c
Коммит 6af8c2f83e
18 изменённых файлов: 20 добавлений и 23 удалений

Просмотреть файл

@@ -1,4 +1,4 @@
@import 'sass/utils/_mixins';
@import 'utils/_mixins';
@import './mixins';
.BillingSubscriptions {

Просмотреть файл

@@ -1,5 +1,5 @@
@import 'sass/utils/variables';
@import 'sass/utils/functions';
@import 'utils/variables';
@import 'utils/functions';
.AbstractList {
padding: 1rem 2rem 2rem 2rem;

Просмотреть файл

@@ -1,4 +1,4 @@
@import 'sass/utils/module';
@import 'utils/variables';
.TeamRow {
&:nth-child(odd) {

Просмотреть файл

@@ -1,4 +1,4 @@
@import "sass/utils/_mixins";
@import 'utils/_mixins';
table.systemUsersTable {
thead {

Просмотреть файл

@@ -1,5 +1,3 @@
@import '../../sass/utils/module';
.DndModal {
width: 600px;

Просмотреть файл

@@ -1,4 +1,4 @@
@import 'sass/utils/_mixins';
@import 'utils/_mixins';
.InviteView {
&__sectionTitle {

Просмотреть файл

@@ -1,4 +1,4 @@
@import 'sass/utils/variables';
@import 'utils/variables';
.tooltip-container {
opacity: 0;

Просмотреть файл

@@ -1,5 +1,5 @@
@import "sass/utils/functions";
@import "utils/variables";
@import 'utils/functions';
@import 'utils/variables';
.markdown-image-expand {
position: relative;

Просмотреть файл

@@ -1,5 +1,3 @@
@import '../../sass/utils/module';
.post-reminder-modal {
.modal-body {
overflow: visible;

Просмотреть файл

@@ -1,5 +1,5 @@
@import 'sass/utils/mixins';
@import 'sass/utils/functions';
@import 'utils/mixins';
@import 'utils/functions';
.reaction-emoji--large img {
width: 48px;

Просмотреть файл

@@ -1,6 +1,6 @@
@charset "UTF-8";
@import 'sass/utils/variables';
@import 'utils/variables';
.nav-pills__unread-indicator {
position: absolute;

Просмотреть файл

@@ -1,7 +1,7 @@
// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
// See LICENSE.txt for license information.
@import "sass/utils/_mixins";
@import 'utils/_mixins';
.ThreadItem {
position: relative;

Просмотреть файл

@@ -1,4 +1,4 @@
@import 'utils/module';
@import 'utils/variables';
.AdminPanel {
overflow: hidden;

Просмотреть файл

@@ -1,4 +1,4 @@
@import '../../../../sass/utils/module';
@import 'utils/variables';
.Menu {
.MenuItem {

Просмотреть файл

@@ -1,4 +1,4 @@
@import 'utils/module';
@import 'utils/functions';
.MenuWrapper {
position: relative;

Просмотреть файл

@@ -1,6 +1,6 @@
@charset 'UTF-8';
@import 'utils/module';
@import 'utils/functions';
.Separator {
position: relative;

Просмотреть файл

@@ -1,6 +1,7 @@
@charset 'UTF-8';
@import 'utils/module';
@import 'utils/mixins';
@import 'utils/variables';
.TeamIcon__content {
display: flex;

Просмотреть файл

@@ -97,7 +97,7 @@ var config = {
loader: 'sass-loader',
options: {
sassOptions: {
includePaths: ['src', 'src/sass'],
includePaths: ['src/sass'],
},
},
},