Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
N
next.js
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Alex
next.js
Commits
a7a924f2
Commit
a7a924f2
authored
Jan 10, 2020
by
Joe Haddad
Committed by
JJ Kasper
Jan 10, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Disable New CSS For Sass, Less, and Stylus (#10043)
parent
5c6a20db
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
58 additions
and
11 deletions
+58
-11
webpack-config.ts
packages/next/build/webpack-config.ts
+23
-11
next.config.js
test/integration/legacy-sass/next.config.js
+2
-0
index.js
test/integration/legacy-sass/pages/index.js
+3
-0
style.scss
test/integration/legacy-sass/styles/style.scss
+4
-0
index.test.js
test/integration/legacy-sass/test/index.test.js
+26
-0
No files found.
packages/next/build/webpack-config.ts
View file @
a7a924f2
...
@@ -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
)
{
...
...
test/integration/legacy-sass/next.config.js
0 → 100644
View file @
a7a924f2
const
withSass
=
require
(
'@zeit/next-sass'
)
module
.
exports
=
withSass
({})
test/integration/legacy-sass/pages/index.js
0 → 100644
View file @
a7a924f2
import
'../styles/style.scss'
export
default
()
=>
<
div
className
=
"example"
>
Hello
World
!<
/div
>
test/integration/legacy-sass/styles/style.scss
0 → 100644
View file @
a7a924f2
$color
:
#2ecc71
;
.example
{
background-color
:
$color
;
}
test/integration/legacy-sass/test/index.test.js
0 → 100644
View file @
a7a924f2
/* 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
)
})
})
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment