-
Notifications
You must be signed in to change notification settings - Fork 26.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add support for sass-loader prependData option (#12277)
This PR adds support for prepending sass code before the actual entry file. It's common for developers to import their sass mixins and variables once on their project config so they don't need to import them on every file that requires it. Frameworks like gatsby and nuxt.js already support that handy feature. The way it works is: ``` /// next.config.js module.exports = { experimental: { sassOptions: { prependData: ` /// Scss code that you want to be /// prepended to every single scss file. `, }, }, } ``` Fixes #11617 and duplicates
- Loading branch information
Showing
5 changed files
with
51 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
7 changes: 7 additions & 0 deletions
7
test/integration/scss-fixtures/basic-module-prepend-data/next.config.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
module.exports = { | ||
sassOptions: { | ||
prependData: ` | ||
$var: red; | ||
`, | ||
}, | ||
} |
9 changes: 9 additions & 0 deletions
9
test/integration/scss-fixtures/basic-module-prepend-data/pages/index.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
import { redText } from './index.module.scss' | ||
|
||
export default function Home() { | ||
return ( | ||
<div id="verify-red" className={redText}> | ||
This text should be red. | ||
</div> | ||
) | ||
} |
3 changes: 3 additions & 0 deletions
3
test/integration/scss-fixtures/basic-module-prepend-data/pages/index.module.scss
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
.redText { | ||
color: $var; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters