Files
vue-cli/packages/@vue/cli/lib/util/inferRootOptions.js
Haoqun Jiang f4e6c33044 chore!: default to dart sass for sass option of cssPreprocessor (#3921)
BREAKING CHANGE:
Preset generated before v3.4.0 may contain a `"cssPreprocessor": "sass"`
field. It now means dart-sass rather than node-sass.

`rootOptions.cssPreprocessor === 'sass'` now also means dart sass.
May affect those generator plugins who depends on this field
2019-04-30 23:33:37 +08:00

34 lines
796 B
JavaScript

// Infer rootOptions for individual generators being invoked
// in an existing project.
module.exports = function inferRootOptions (pkg) {
const rootOptions = {}
const deps = Object.assign({}, pkg.dependencies, pkg.devDependencies)
// projectName
rootOptions.projectName = pkg.name
// router
if ('vue-router' in deps) {
rootOptions.router = true
}
// vuex
if ('vuex' in deps) {
rootOptions.vuex = true
}
// cssPreprocessors
if ('sass' in deps) {
rootOptions.cssPreprocessor = 'sass'
} else if ('node-sass' in deps) {
rootOptions.cssPreprocessor = 'node-sass'
} else if ('less-loader' in deps) {
rootOptions.cssPreprocessor = 'less'
} else if ('stylus-loader' in deps) {
rootOptions.cssPreprocessor = 'stylus'
}
return rootOptions
}