Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add sassOption implementation to support sass-embedded #64577

Merged
merged 23 commits into from
Jun 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
df5b21a
Add implementation to sassOptions in order to support sass-embedded
joostmeijles Apr 16, 2024
266d156
Create cjs for upgraded sass-loader
joostmeijles Apr 17, 2024
97cb70e
Fix test
joostmeijles Apr 17, 2024
8598b02
Add sass-embedded as alternative to all sass tests
joostmeijles Apr 18, 2024
5dd58f6
Fix tests that failed due to double next config
joostmeijles Apr 18, 2024
1db7fe1
Merge branch 'canary' into sass-embedded
joostmeijles Apr 24, 2024
9d37593
Fix test name: rename var to dependencies
joostmeijles Apr 24, 2024
ceff5e1
Fix: use relative path to prevent "leaves the filesystem root" error
joostmeijles Apr 24, 2024
fb6e2f0
Skip SCSS Support tests for Turbopack
joostmeijles Apr 24, 2024
45651b2
Merge branch 'canary' into sass-embedded
joostmeijles Apr 24, 2024
8a6c11b
Remove explicit skip; rely on turbopack-build-tests-manifest.json
joostmeijles May 6, 2024
b33fccf
Merge branch 'canary' into sass-embedded
joostmeijles May 6, 2024
21bd303
Add sass implementation to test match string
joostmeijles May 6, 2024
e10debd
Merge branch 'sass-embedded' of https://github.com/joostmeijles/next.…
joostmeijles May 6, 2024
a273255
Merge branch 'canary' into sass-embedded
joostmeijles May 6, 2024
737eca2
Add dependencies text to turbopack test manifest
joostmeijles Jun 3, 2024
c3b2a57
Merge branch 'canary' into sass-embedded
joostmeijles Jun 13, 2024
d534577
Fix prettier formatting
joostmeijles Jun 13, 2024
58bea86
Fix turbopack-build-tests-manifest.json for compilation-and-prefixing
joostmeijles Jun 14, 2024
e3374eb
Merge branch 'canary' into sass-embedded
joostmeijles Jun 14, 2024
35e281b
Fix merge error
joostmeijles Jun 14, 2024
2ac8ddf
Merge branch 'canary' into sass-embedded
joostmeijles Jun 14, 2024
21ed482
Merge branch 'canary' into sass-embedded
ztanner Jun 19, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ pub async fn maybe_add_sass_loader(
loader: "next/dist/compiled/sass-loader".into(),
options: take(
serde_json::json!({
"implementation": sass_options.get("implementation"),
"sourceMap": true,
"sassOptions": sass_options,
"additionalData": additional_data
Expand Down
2 changes: 1 addition & 1 deletion packages/next/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -292,7 +292,7 @@
"react-is": "19.0.0-canary-94eed63c49-20240425",
"react-refresh": "0.12.0",
"regenerator-runtime": "0.13.4",
"sass-loader": "12.4.0",
"sass-loader": "12.6.0",
"schema-utils2": "npm:schema-utils@2.7.1",
"schema-utils3": "npm:schema-utils@3.0.0",
"semver": "7.3.2",
Expand Down
2 changes: 2 additions & 0 deletions packages/next/src/build/webpack/config/blocks/css/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,7 @@ export const css = curry(async function css(
const {
prependData: sassPrependData,
additionalData: sassAdditionalData,
implementation: sassImplementation,
...sassOptions
} = ctx.sassOptions

Expand All @@ -167,6 +168,7 @@ export const css = curry(async function css(
{
loader: require.resolve('next/dist/compiled/sass-loader'),
options: {
implementation: sassImplementation,
// Source maps are required so that `resolve-url-loader` can locate
// files original to their source directory.
sourceMap: true,
Expand Down
2 changes: 1 addition & 1 deletion packages/next/src/compiled/sass-loader/cjs.js

Large diffs are not rendered by default.

16 changes: 7 additions & 9 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

80 changes: 46 additions & 34 deletions test/e2e/app-dir/scss/3rd-party-module/3rd-party-module.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,42 +3,54 @@
import { nextTestSetup } from 'e2e-utils'
import { colorToRgb } from 'next-test-utils'

describe('3rd Party CSS Module Support', () => {
const { next } = nextTestSetup({
files: __dirname,
dependencies: {
sass: '1.54.0',
describe.each([
{ dependencies: { sass: '1.54.0' }, nextConfig: undefined },
{
dependencies: { 'sass-embedded': '1.75.0' },
nextConfig: {
sassOptions: {
implementation: 'sass-embedded',
},
},
})
},
])(
'3rd Party CSS Module Support ($dependencies)',
({ dependencies, nextConfig }) => {
const { next } = nextTestSetup({
files: __dirname,
dependencies,
nextConfig,
})

it('should render the module', async () => {
const browser = await next.browser('/')
// Bar
expect(
await browser
.elementByCss('#verify-div .bar')
.getComputedCss('background-color')
).toBe(colorToRgb('blue'))
it('should render the module', async () => {
const browser = await next.browser('/')
// Bar
expect(
await browser
.elementByCss('#verify-div .bar')
.getComputedCss('background-color')
).toBe(colorToRgb('blue'))

// Baz
expect(
await browser
.elementByCss('#verify-div .baz')
.getComputedCss('background-color')
).toBe(colorToRgb('blue'))
// Baz
expect(
await browser
.elementByCss('#verify-div .baz')
.getComputedCss('background-color')
).toBe(colorToRgb('blue'))

// Lol
expect(
await browser
.elementByCss('#verify-div .lol')
.getComputedCss('background-color')
).toBe(colorToRgb('red'))
// Lol
expect(
await browser
.elementByCss('#verify-div .lol')
.getComputedCss('background-color')
).toBe(colorToRgb('red'))

// Lel
expect(
await browser
.elementByCss('#verify-div .lel')
.getComputedCss('background-color')
).toBe(colorToRgb('green'))
})
})
// Lel
expect(
await browser
.elementByCss('#verify-div .lel')
.getComputedCss('background-color')
).toBe(colorToRgb('green'))
})
}
)
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,37 @@
import { nextTestSetup } from 'e2e-utils'
import { colorToRgb } from 'next-test-utils'

describe('Basic Module Additional Data Support', () => {
const { next } = nextTestSetup({
files: __dirname,
dependencies: {
sass: '1.54.0',
const sassOptions = {
additionalData: `
$var: red;
`,
}

describe.each([
{ dependencies: { sass: '1.54.0' }, nextConfig: { sassOptions } },
{
dependencies: { 'sass-embedded': '1.75.0' },
nextConfig: {
sassOptions: {
...sassOptions,
implementation: 'sass-embedded',
},
},
})
},
])(
'Basic Module Additional Data Support ($dependencies)',
({ dependencies, nextConfig }) => {
const { next } = nextTestSetup({
files: __dirname,
dependencies,
nextConfig,
})

it('should render the module', async () => {
const browser = await next.browser('/')
expect(
await browser.elementByCss('#verify-red').getComputedCss('color')
).toBe(colorToRgb('red'))
})
})
it('should render the module', async () => {
const browser = await next.browser('/')
expect(
await browser.elementByCss('#verify-red').getComputedCss('color')
).toBe(colorToRgb('red'))
})
}
)

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,20 +1,36 @@
/* eslint-env jest */

import { nextTestSetup } from 'e2e-utils'
import { colorToRgb } from 'next-test-utils'

describe('Basic Module Include Paths Support', () => {
const { next } = nextTestSetup({
files: __dirname,
dependencies: {
sass: '1.54.0',
const sassOptions = {
includePaths: ['./styles'],
}

describe.each([
{ dependencies: { sass: '1.54.0' }, nextConfig: { sassOptions } },
{
dependencies: { 'sass-embedded': '1.75.0' },
nextConfig: {
sassOptions: {
...sassOptions,
implementation: 'sass-embedded',
},
},
})
},
])(
'Basic Module Include Paths Support ($dependencies)',
({ dependencies, nextConfig }) => {
const { next } = nextTestSetup({
files: __dirname,
dependencies,
nextConfig,
})

it('should render the module', async () => {
const browser = await next.browser('/')
expect(
await browser.elementByCss('#verify-red').getComputedCss('color')
).toBe(colorToRgb('red'))
})
})
it('should render the module', async () => {
const browser = await next.browser('/')
expect(
await browser.elementByCss('#verify-red').getComputedCss('color')
).toBe(colorToRgb('red'))
})
}
)

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,37 @@
import { nextTestSetup } from 'e2e-utils'
import { colorToRgb } from 'next-test-utils'

describe('Basic Module Prepend Data Support', () => {
const { next } = nextTestSetup({
files: __dirname,
dependencies: {
sass: '1.54.0',
const sassOptions = {
prependData: `
$var: red;
`,
}

describe.each([
{ dependencies: { sass: '1.54.0' }, nextConfig: { sassOptions } },
{
dependencies: { 'sass-embedded': '1.75.0' },
nextConfig: {
sassOptions: {
...sassOptions,
implementation: 'sass-embedded',
},
},
})
},
])(
'Basic Module Prepend Data Support ($dependencies)',
({ dependencies, nextConfig }) => {
const { next } = nextTestSetup({
files: __dirname,
dependencies,
nextConfig,
})

it('should render the module', async () => {
const browser = await next.browser('/')
expect(
await browser.elementByCss('#verify-red').getComputedCss('color')
).toBe(colorToRgb('red'))
})
})
it('should render the module', async () => {
const browser = await next.browser('/')
expect(
await browser.elementByCss('#verify-red').getComputedCss('color')
).toBe(colorToRgb('red'))
})
}
)

This file was deleted.

Loading
Loading