Skip to content

Commit

Permalink
fix: add support for sass-loader > 8.0.0 (#122)
Browse files Browse the repository at this point in the history
fixes #119
  • Loading branch information
DRoet authored and johnleider committed Oct 17, 2019
1 parent f086490 commit 25baea2
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 4 deletions.
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,8 @@
"vuetify-loader": "^1.2.2"
},
"dependencies": {
"shelljs": "^0.8.3"
"shelljs": "^0.8.3",
"semver": "^6.0.0"
},
"husky": {
"hooks": {
Expand Down
4 changes: 2 additions & 2 deletions util/__tests__/__snapshots__/helpers.spec.js.snap
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

exports[`helpers.js should merge sass variable rules 1`] = `
Object {
"data": "@import '@/sass/variables.sass'
"prependData": "@import '@/sass/variables.sass'
@import '@/sass/variables.scss'
@import '@/scss/variables.sass'
@import '@/scss/variables.scss'
Expand All @@ -20,7 +20,7 @@ Object {

exports[`helpers.js should merge sass variable rules 2`] = `
Object {
"data": "@import '@/sass/variables.sass';
"prependData": "@import '@/sass/variables.sass';
@import '@/sass/variables.scss';
@import '@/scss/variables.sass';
@import '@/scss/variables.scss';
Expand Down
12 changes: 11 additions & 1 deletion util/helpers.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
// Imports
const semver = require('semver')
const fs = require('fs')

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

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

opt.data = data.join('\n')
let sassLoaderVersion
try {
sassLoaderVersion = semver.major(require('sass-loader/package.json').version)
} catch (e) {}

if (sassLoaderVersion < 8) {
opt.data = data.join('\n')
} else {
opt.prependData = data.join('\n')
}

return opt
}
Expand Down

0 comments on commit 25baea2

Please sign in to comment.