@@ -8,7 +8,7 @@ const { removeSync } = require('fs-extra')
88
99const appPaths = require ( './app-paths' )
1010const parseEnv = require ( './parse-env' )
11- const { log } = require ( './helpers/logger' )
11+ const { log, warn , tip } = require ( './helpers/logger' )
1212const extensionRunner = require ( './app-extension/extensions-runner' )
1313
1414const quasarVitePluginIndexHtmlTransform = require ( './plugins/vite.index-html-transform' )
@@ -17,13 +17,9 @@ const { dependencies:cliDepsObject } = require(appPaths.resolve.cli('package.jso
1717const appPkgFile = appPaths . resolve . app ( 'package.json' )
1818const 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-
2520function 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
0 commit comments