mirror of
https://github.com/vuejs/vue-cli.git
synced 2026-01-20 22:30:05 -06:00
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
34 lines
796 B
JavaScript
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
|
|
}
|