Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: add support for sass-loader > 8.0.0 #122

Merged
merged 1 commit into from Oct 17, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
3 changes: 2 additions & 1 deletion package.json
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
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
@@ -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)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sass-loader should be declared in peerDependencies

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why?

Copy link
Contributor

@merceyz merceyz Oct 22, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To support Yarn PnP, but most importantly, to ensure the package manager is aware of it so it can place it in a location where vue-cli-plugin-vuetify can require it.

It can be marked as a optional peer dependency to avoid warnings

cc @arcanis

} catch (e) {}

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

return opt
}
Expand Down