Skip to content

Commit 5fd2b7f

Browse files
authored
chore: update sass to v1.71.0 (#22531)
## Updates Sass Updates `sass` to the latest version, while also switching to `sass-embedded` (maintained by the same team, is faster than sass, and we don't need to patch it anymore!). ## Moves fonts This PR also moves the `fonts` directory to be relative to the CSS file that imports it. This helps with two things: 1. its just nice to use _real_ relative paths to files that are using them while developing (not just in the final build) 2. the webpack build will work differently: it _requires_ all the imports to use relative paths (there is a hack I can put in place to not require relative paths, but meh. I don't want to do that :-) ). ## Use `@use` for the design-system instead of `@import` The biggest change in this PR is moving towards the use of `@use` and away from `@import`, which is slated to be completely removed from Sass in some distance future release. ### Bonus savings! This PR also fixes a the duplication of CSS, as the design-system previously included actual CSS (colors, fonts, and font-awesome styles) and reduces the output size from ~1700KB to ~1300KB. The issue with that some devs were already `@use`ing the `design-system`, which was re-including its all of its rules (mentioned above). ### ⚠️ Changes How We Write SCSS So, from now on, if someone wants to use something from the design-system they'll need to put `@use design-system";` at the top of the SCSS file.
1 parent 9f13517 commit 5fd2b7f

File tree

219 files changed

+1507
-943
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

219 files changed

+1507
-943
lines changed

.storybook/5.BREAKPOINTS.stories.mdx

Lines changed: 18 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -34,51 +34,55 @@ $screen-lg-min /* 1280px */
3434
### Mixins
3535

3636
```css
37+
@use "design-system";
38+
3739
/* Max screen size */
38-
@include screen-sm-max {
40+
@include design-system.screen-sm-max {
3941
/* equivalent css @media screen and (max-width: 575px) */
4042
}
41-
@include screen-md-max {
43+
@include design-system.screen-md-max {
4244
/* equivalent css @media screen and (max-width: 767px) */
4345
}
44-
@include screen-lg-max {
46+
@include design-system.screen-lg-max {
4547
/* equivalent css @media screen and (max-width: 1279px) */
4648
}
4749

4850
/* Min screen size */
49-
@include screen-sm-min {
51+
@include design-system.screen-sm-min {
5052
/* equivalent css @media screen and (min-width: 576px) */
5153
}
52-
@include screen-md-min {
54+
@include design-system.screen-md-min {
5355
/* equivalent css @media screen and (min-width: 768px) */
5456
}
55-
@include screen-lg-min {
57+
@include design-system.screen-lg-min {
5658
/* equivalent css @media screen and (min-width: 1280px) */
5759
}
5860
```
5961

6062
Migrating from the old sass variables to the new mixins looks like this
6163

6264
```css
65+
@use "design-system";
66+
6367
/* Max width */
6468
/* Instead of the media query and sass variable */
65-
@media screen and (max-width: $break-small) {
69+
@media screen and (max-width: design-system.$break-small) {
6670
right: 16px;
6771
}
6872

6973
/* Use the sass mixin */
70-
@include screen-sm-max {
74+
@include design-system.screen-sm-max {
7175
right: 16px;
7276
}
7377

7478
/* Min width */
7579
/* Instead of the media query and sass variable */
76-
@media screen and (min-width: $break-large) {
80+
@media screen and (min-width: design-system.$break-large) {
7781
left: 16px;
7882
}
7983

8084
/* Use the sass mixin */
81-
@include screen-sm-min {
85+
@include design-system.screen-sm-min {
8286
left: 16px;
8387
}
8488
```
@@ -113,12 +117,14 @@ Don't use static media queries in your code.
113117
Do use the provided Sass mixins
114118

115119
```css
120+
@use "design-system";
121+
116122
.account-menu {
117-
@include screen-md-min {
123+
@include design-system.screen-md-min {
118124
right: calc((100vw - 80vw) / 2);
119125
}
120126

121-
@include screen-lg-min {
127+
@include design-system.screen-lg-min {
122128
right: calc((100vw - 65vw) / 2);
123129
}
124130
}

.storybook/main.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,9 +69,9 @@ module.exports = {
6969
loader: 'sass-loader',
7070
options: {
7171
sourceMap: true,
72-
implementation: require('sass'),
72+
implementation: require('sass-embedded'),
7373
sassOptions: {
74-
includePaths: ['ui/css/'],
74+
includePaths: ['ui/css/', 'node_modules/',],
7575
},
7676
},
7777
},

.yarn/patches/sass-npm-1.35.2-6df4e15d13.patch

Lines changed: 0 additions & 29 deletions
This file was deleted.

development/build/sass-compiler.js

Lines changed: 0 additions & 12 deletions
This file was deleted.

development/build/static.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@ function getCopyTargets(
127127
dest: `images/contract`,
128128
},
129129
{
130-
src: `./app/fonts/`,
130+
src: `./ui/css/utilities/fonts/`,
131131
dest: `fonts`,
132132
},
133133
{
@@ -139,6 +139,7 @@ function getCopyTargets(
139139
'@fortawesome/fontawesome-free',
140140
'webfonts/',
141141
),
142+
// update this location in styles.js if it changes
142143
dest: `fonts/fontawesome`,
143144
},
144145
{

development/build/styles.js

Lines changed: 16 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,11 @@ const sourcemaps = require('gulp-sourcemaps');
77
const rtlcss = require('postcss-rtlcss');
88
const postcss = require('gulp-postcss');
99
const pump = pify(require('pump'));
10+
const sass = require('sass-embedded');
11+
const gulpSass = require('gulp-sass')(sass);
1012
const { TASKS } = require('./constants');
1113
const { createTask } = require('./task');
1214

13-
let sass;
14-
1515
// scss compilation and autoprefixing tasks
1616
module.exports = createStyleTasks;
1717

@@ -64,18 +64,25 @@ function createStyleTasks({ livereload }) {
6464
}
6565

6666
async function buildScssPipeline(src, dest, devMode) {
67-
if (!sass) {
68-
// use our own compiler which runs sass in its own process
69-
// in order to not pollute the intrinsics
70-
// eslint-disable-next-line node/global-require
71-
sass = require('gulp-sass')(require('./sass-compiler'));
72-
}
7367
await pump(
7468
...[
7569
// pre-process
7670
gulp.src(src),
7771
devMode && sourcemaps.init(),
78-
sass().on('error', sass.logError),
72+
gulpSass({
73+
// The order of includePaths is important; prefer our own
74+
// folders over `node_modules`
75+
includePaths: [
76+
// enables shortcuts to `@use design-system`, `@use utilities`, etc.
77+
'ui/css/',
78+
'node_modules/',
79+
],
80+
functions: {
81+
// Tell sass where to find the font-awesome font files
82+
// update this location in static.js if it changes
83+
'-mm-fa-path()': () => new sass.SassString('./fonts/fontawesome'),
84+
},
85+
}).on('error', gulpSass.logError),
7986
postcss([autoprefixer(), rtlcss()]),
8087
devMode && sourcemaps.write(),
8188
gulp.dest(dest),

development/ts-migration-dashboard/scripts/build-app.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import endOfStream from 'end-of-stream';
99
import pump from 'pump';
1010
import gulp from 'gulp';
1111
import gulpSass from 'gulp-sass';
12-
import sass from 'sass';
12+
import * as sass from 'sass-embedded';
1313
import sourcemaps from 'gulp-sourcemaps';
1414
import autoprefixer from 'gulp-autoprefixer';
1515
import fg from 'fast-glob';

lavamoat/browserify/beta/policy.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,8 @@
3737
"@ensdomains/content-hash>cids>multihashes": {
3838
"packages": {
3939
"@ensdomains/content-hash>cids>multibase": true,
40-
"@ensdomains/content-hash>cids>uint8arrays": true,
41-
"@ensdomains/content-hash>multihashes>varint": true
40+
"@ensdomains/content-hash>cids>multihashes>varint": true,
41+
"@ensdomains/content-hash>cids>uint8arrays": true
4242
}
4343
},
4444
"@ensdomains/content-hash>cids>uint8arrays": {
@@ -66,7 +66,7 @@
6666
"@ensdomains/content-hash>multicodec": {
6767
"packages": {
6868
"@ensdomains/content-hash>multicodec>uint8arrays": true,
69-
"@ensdomains/content-hash>multicodec>varint": true
69+
"sass-embedded>varint": true
7070
}
7171
},
7272
"@ensdomains/content-hash>multicodec>uint8arrays": {

lavamoat/browserify/desktop/policy.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,8 @@
3737
"@ensdomains/content-hash>cids>multihashes": {
3838
"packages": {
3939
"@ensdomains/content-hash>cids>multibase": true,
40-
"@ensdomains/content-hash>cids>uint8arrays": true,
41-
"@ensdomains/content-hash>multihashes>varint": true
40+
"@ensdomains/content-hash>cids>multihashes>varint": true,
41+
"@ensdomains/content-hash>cids>uint8arrays": true
4242
}
4343
},
4444
"@ensdomains/content-hash>cids>uint8arrays": {
@@ -66,7 +66,7 @@
6666
"@ensdomains/content-hash>multicodec": {
6767
"packages": {
6868
"@ensdomains/content-hash>multicodec>uint8arrays": true,
69-
"@ensdomains/content-hash>multicodec>varint": true
69+
"sass-embedded>varint": true
7070
}
7171
},
7272
"@ensdomains/content-hash>multicodec>uint8arrays": {

lavamoat/browserify/flask/policy.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,8 @@
3737
"@ensdomains/content-hash>cids>multihashes": {
3838
"packages": {
3939
"@ensdomains/content-hash>cids>multibase": true,
40-
"@ensdomains/content-hash>cids>uint8arrays": true,
41-
"@ensdomains/content-hash>multihashes>varint": true
40+
"@ensdomains/content-hash>cids>multihashes>varint": true,
41+
"@ensdomains/content-hash>cids>uint8arrays": true
4242
}
4343
},
4444
"@ensdomains/content-hash>cids>uint8arrays": {
@@ -66,7 +66,7 @@
6666
"@ensdomains/content-hash>multicodec": {
6767
"packages": {
6868
"@ensdomains/content-hash>multicodec>uint8arrays": true,
69-
"@ensdomains/content-hash>multicodec>varint": true
69+
"sass-embedded>varint": true
7070
}
7171
},
7272
"@ensdomains/content-hash>multicodec>uint8arrays": {

0 commit comments

Comments
 (0)