Commit a7a924f2 authored by Joe Haddad's avatar Joe Haddad Committed by JJ Kasper

Disable New CSS For Sass, Less, and Stylus (#10043)

parent 5c6a20db
...@@ -865,18 +865,31 @@ export default async function getBaseWebpackConfig( ...@@ -865,18 +865,31 @@ export default async function getBaseWebpackConfig(
return false return false
} }
const fileName = '/tmp/test.css' const fileNames = [
'/tmp/test.css',
if (rule instanceof RegExp && rule.test(fileName)) { '/tmp/test.scss',
'/tmp/test.sass',
'/tmp/test.less',
'/tmp/test.styl',
]
if (rule instanceof RegExp && fileNames.some(input => rule.test(input))) {
return true return true
} }
if (typeof rule === 'function') { if (typeof rule === 'function') {
try { if (
if (rule(fileName)) { fileNames.some(input => {
return true try {
} if (rule(input)) {
} catch (_) {} return true
}
} catch (_) {}
return false
})
) {
return true
}
} }
if (Array.isArray(rule) && rule.some(canMatchCss)) { if (Array.isArray(rule) && rule.some(canMatchCss)) {
...@@ -888,10 +901,9 @@ export default async function getBaseWebpackConfig( ...@@ -888,10 +901,9 @@ export default async function getBaseWebpackConfig(
if (config.experimental.css) { if (config.experimental.css) {
const hasUserCssConfig = const hasUserCssConfig =
webpackConfig.module && webpackConfig.module?.rules.some(
webpackConfig.module.rules.some(
rule => canMatchCss(rule.test) || canMatchCss(rule.include) rule => canMatchCss(rule.test) || canMatchCss(rule.include)
) ) ?? false
if (hasUserCssConfig) { if (hasUserCssConfig) {
if (webpackConfig.module?.rules.length) { if (webpackConfig.module?.rules.length) {
......
const withSass = require('@zeit/next-sass')
module.exports = withSass({})
import '../styles/style.scss'
export default () => <div className="example">Hello World!</div>
$color: #2ecc71;
.example {
background-color: $color;
}
/* eslint-env jest */
/* global jasmine */
import { remove } from 'fs-extra'
import { nextBuild } from 'next-test-utils'
import { recursiveReadDir } from 'next/dist/lib/recursive-readdir'
import { join } from 'path'
jasmine.DEFAULT_TIMEOUT_INTERVAL = 1000 * 60 * 1
const appDir = join(__dirname, '../')
describe('Legacy Sass Support Should Disable New CSS', () => {
beforeAll(async () => {
await remove(join(appDir, '.next'))
await nextBuild(appDir)
})
it(`should've emitted a single CSS file`, async () => {
const cssFiles = await recursiveReadDir(
join(appDir, '.next', 'static'),
/\.css$/
)
expect(cssFiles.length).toBe(1)
})
})
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment