Skip to content

Commit ef41d24

Browse files
committed
feat(app-vite): improve messaging for quasar.config.js > build > vitePlugins; allow more formats, warn when a better format can be used
1 parent 24960e8 commit ef41d24

File tree

2 files changed

+21
-9
lines changed

2 files changed

+21
-9
lines changed

app-vite/lib/config-tools.js

Lines changed: 20 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ const { removeSync } = require('fs-extra')
88

99
const appPaths = require('./app-paths')
1010
const parseEnv = require('./parse-env')
11-
const { log } = require('./helpers/logger')
11+
const { log, warn, tip } = require('./helpers/logger')
1212
const extensionRunner = require('./app-extension/extensions-runner')
1313

1414
const quasarVitePluginIndexHtmlTransform = require('./plugins/vite.index-html-transform')
@@ -17,13 +17,9 @@ const { dependencies:cliDepsObject } = require(appPaths.resolve.cli('package.jso
1717
const appPkgFile = appPaths.resolve.app('package.json')
1818
const cliDeps = Object.keys(cliDepsObject)
1919

20-
function printInvalidSyntax (name) {
21-
console.error('[Quasar CLI] quasar.config.js > invalid Vite plugin specified:', name)
22-
console.error(`Correct form: [ 'my-vite-plugin-name', { /* opts */ } ]`)
23-
}
24-
2520
function parseVitePlugins (entries) {
2621
const acc = []
22+
let showTip = false
2723

2824
entries.forEach(entry => {
2925
if (!entry) {
@@ -36,7 +32,11 @@ function parseVitePlugins (entries) {
3632
}
3733

3834
if (Array.isArray(entry) === false) {
39-
printInvalidSyntax(name)
35+
if (typeof entry === 'function') {
36+
showTip = true
37+
}
38+
39+
acc.push(entry)
4040
return
4141
}
4242

@@ -47,21 +47,32 @@ function parseVitePlugins (entries) {
4747
return
4848
}
4949

50+
if (Object(name) === name) {
51+
acc.push(name)
52+
return
53+
}
54+
5055
if (typeof name !== 'string') {
51-
printInvalidSyntax(name)
56+
console.log(name)
57+
warn('quasar.config.js > invalid Vite plugin specified: ' + name)
58+
warn(`Correct form: [ 'my-vite-plugin-name', { /* opts */ } ] or [ pluginFn, { /* opts */ } ]`)
5259
return
5360
}
5461

5562
const plugin = getPackage(name)
5663

5764
if (!plugin) {
58-
console.error('[Quasar CLI] quasar.config.js > invalid Vite plugin specified (cannot find it):', name)
65+
warn('quasar.config.js > invalid Vite plugin specified (cannot find it): ' + name)
5966
return
6067
}
6168

6269
acc.push((plugin.default || plugin)(opts))
6370
})
6471

72+
if (showTip === true) {
73+
tip(`If you want changes to quasar.config.js > build > vitePlugins to be picked up, specify them in this form: [ [ 'plugin-name', { /* opts */ } ], ... ] or [ [ pluginFn, { /* opts */ } ], ... ]`)
74+
}
75+
6576
return acc
6677
}
6778

app-vite/lib/quasar-config-file.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -185,6 +185,7 @@ class QuasarConfFile {
185185

186186
if (result.error !== void 0) {
187187
warn(result.error)
188+
warn('Changes to quasar.config.js have NOT been applied due to error above')
188189
}
189190
else {
190191
log(`Applying quasar.config.js changes`)

0 commit comments

Comments
 (0)