Skip to content

Commit

Permalink
chore: migrate scss import to use
Browse files Browse the repository at this point in the history
  • Loading branch information
bluwy committed Oct 25, 2024
1 parent 58bc781 commit e6e65ab
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 7 deletions.
2 changes: 1 addition & 1 deletion packages/e2e-tests/css-dev-sourcemap/src/App.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<div class="foo">magenta</div>

<style lang="scss">
@import './foo';
@use './foo';
#test {
& {
color: red;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ if (!isBuild) {
expect(await getColor('h2')).toBe('magenta');
await editFileAndWaitForHmrComplete(
'src/lib/multifile/MultiFile.scss',
(c) => c.replace("@import 'someImport';", "/*@import 'someImport';*/"),
(c) => c.replace("@use 'someImport';", "/*@use 'someImport';*/"),
'/src/lib/multifile/MultiFile.svelte?svelte&type=style&lang.css'
);
expect(await getColor('h2')).toBe('black');
Expand All @@ -93,7 +93,7 @@ if (!isBuild) {
expect(await getColor('h2')).toBe('black');
await editFileAndWaitForHmrComplete(
'src/lib/multifile/MultiFile.scss',
(c) => c.replace("/*@import 'someImport';*/", "/*@import 'someImport';*/\n@import 'foo';"),
(c) => c.replace("/*@use 'someImport';*/", "/*@use 'someImport';*/\n@use 'foo';"),
'/src/lib/multifile/MultiFile.svelte?svelte&type=style&lang.css'
);
expect(await getColor('h2')).toBe('maroon');
Expand Down Expand Up @@ -135,7 +135,7 @@ if (!isBuild) {
expect(errorOverlay2).toBeFalsy();
await editFileAndWaitForHmrComplete(
'src/lib/multifile/MultiFile.scss',
(c) => c.replace("@import 'foo';", ''),
(c) => c.replace("@use 'foo';", ''),
'/src/lib/multifile/MultiFile.svelte?svelte&type=style&lang.css'
);
expect(await getColor('h2')).toBe('black');
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
@import 'someImport';
@use 'someImport';
h1 {
color: blue;
}
3 changes: 1 addition & 2 deletions packages/vite-plugin-svelte/__tests__/preprocess.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ describe('vitePreprocess', () => {
);
expect(style).toBeDefined();
const scss = `
@import './foo';
@use './foo';
.foo {
&.bar {
color: red;
Expand All @@ -69,7 +69,6 @@ describe('vitePreprocess', () => {
expect(processed).toBeDefined();
const { code, map, dependencies } = processed;
expect(code).toBe('.foo {\n color: green;\n}\n\n.foo.bar {\n color: red;\n}');
expect(map.file).toBe('File.svelte');
expect(map.sources.length).toBe(2);
expect(map.sources[0]).toBe('foo.scss');
expect(map.sources[1]).toBe('File.svelte');
Expand Down

0 comments on commit e6e65ab

Please sign in to comment.