Skip to content

Commit 25baea2

Browse files
DRoetjohnleider
authored andcommitted
fix: add support for sass-loader > 8.0.0 (#122)
fixes #119
1 parent f086490 commit 25baea2

File tree

3 files changed

+15
-4
lines changed

3 files changed

+15
-4
lines changed

package.json

+2-1
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,8 @@
3535
"vuetify-loader": "^1.2.2"
3636
},
3737
"dependencies": {
38-
"shelljs": "^0.8.3"
38+
"shelljs": "^0.8.3",
39+
"semver": "^6.0.0"
3940
},
4041
"husky": {
4142
"hooks": {

util/__tests__/__snapshots__/helpers.spec.js.snap

+2-2
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
exports[`helpers.js should merge sass variable rules 1`] = `
44
Object {
5-
"data": "@import '@/sass/variables.sass'
5+
"prependData": "@import '@/sass/variables.sass'
66
@import '@/sass/variables.scss'
77
@import '@/scss/variables.sass'
88
@import '@/scss/variables.scss'
@@ -20,7 +20,7 @@ Object {
2020

2121
exports[`helpers.js should merge sass variable rules 2`] = `
2222
Object {
23-
"data": "@import '@/sass/variables.sass';
23+
"prependData": "@import '@/sass/variables.sass';
2424
@import '@/sass/variables.scss';
2525
@import '@/scss/variables.sass';
2626
@import '@/scss/variables.scss';

util/helpers.js

+11-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
// Imports
2+
const semver = require('semver')
23
const fs = require('fs')
34

45
// Check for existence of file and add import
@@ -46,7 +47,16 @@ function mergeRules (api, opt, ext) {
4647

4748
addImports(api, 'lists', data, end)
4849

49-
opt.data = data.join('\n')
50+
let sassLoaderVersion
51+
try {
52+
sassLoaderVersion = semver.major(require('sass-loader/package.json').version)
53+
} catch (e) {}
54+
55+
if (sassLoaderVersion < 8) {
56+
opt.data = data.join('\n')
57+
} else {
58+
opt.prependData = data.join('\n')
59+
}
5060

5161
return opt
5262
}

0 commit comments

Comments
 (0)