Skip to content

Commit 9aaad72

Browse files
committed
fix: fix indentedSyntax issue around scss files
1 parent 9307d8e commit 9aaad72

File tree

2 files changed

+14
-13
lines changed

2 files changed

+14
-13
lines changed

lib/module.js

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ const path = require('path')
22
const fs = require('fs')
33
const consola = require('consola')
44
const merge = require('deepmerge')
5+
const dartSass = require('sass')
56

67
const defaults = {
78
customVariables: [],
@@ -20,13 +21,6 @@ const cdn = {
2021
'fa4': 'https://cdn.jsdelivr.net/npm/[email protected]/css/font-awesome.min.css'
2122
}
2223

23-
const sassLoaderOptions = {
24-
implementation: require('sass'),
25-
sassOptions: {
26-
indentedSyntax: true
27-
}
28-
}
29-
3024
module.exports = function (moduleOptions) {
3125
this.nuxt.hook('build:before', () => {
3226
const options = merge.all([
@@ -44,13 +38,20 @@ module.exports = function (moduleOptions) {
4438
}
4539

4640
// Ensure sass-loader@8 compatibility (https://github.com/webpack-contrib/sass-loader/releases/tag/v8.0.0)
41+
// Cause since loader options validation, this will fail: https://github.com/nuxt/nuxt.js/tree/c8ee9a660809e856c28d8678c6a632bbdd6ed00f/packages/config/src/config/build.js#L50
4742
delete this.options.build.loaders.sass.indentedSyntax
48-
this.options.build.loaders.sass.prependData = this.options.build.loaders.sass.data
49-
delete this.options.build.loaders.sass.data
5043

51-
// Customize sass-loader options
52-
Object.assign(this.options.build.loaders.scss, sassLoaderOptions)
53-
Object.assign(this.options.build.loaders.sass, sassLoaderOptions)
44+
// Customize sass & scss loaders options
45+
Object.assign(this.options.build.loaders.sass, {
46+
implementation: dartSass,
47+
sassOptions: {
48+
indentedSyntax: true
49+
}
50+
})
51+
52+
Object.assign(this.options.build.loaders.scss, {
53+
implementation: dartSass
54+
})
5455

5556
// Custom variables
5657
const sassLoaderData = this.options.build.loaders.sass.prependData

test/module.test.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ describe('module', () => {
6464
build: {
6565
loaders: {
6666
sass: {
67-
data: '$someVariable: #000000'
67+
prependData: '$someVariable: #000000'
6868
}
6969
}
7070
},

0 commit comments

Comments
 (0)