Skip to content

Commit

Permalink
feat(vite): print console diagnostics
Browse files Browse the repository at this point in the history
  • Loading branch information
innocenzi committed Feb 20, 2022
1 parent 5b0239d commit c78c1d5
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 1 deletion.
16 changes: 15 additions & 1 deletion vite-plugin-laravel/src/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -135,13 +135,27 @@ export const config = (options: Options = {}): Plugin => {
server.config.logger.info(`\n ${c.magenta(`${c.bold('LARAVEL')} v${version}`)} ${c.dim(`(using ${c.white.bold(serverConfig.configName)} config)`)}\n`)
server.config.logger.info(` ${c.magenta('➜')} ${c.bold('Application')}: ${c.cyan(env.APP_URL)}`)
server.config.logger.info(` ${c.magenta('➜')} ${c.bold('Environment')}: ${c.dim(env.APP_ENV)}`)

if (!serverConfig.dev_server.enabled) {
const buildPath = `${server.config.root}/public/${serverConfig.build_path}`
const isBuilt = fs.existsSync(buildPath)
const color = isBuilt ? 'yellow' : 'red'
const hint = isBuilt
? `the ${c.bold(serverConfig.build_path)} directory will be used instead`
: `run ${c.bold('vite build')} to be able to preview your application`

server.config.logger.info(c[color](` ${c[color]('➜')} ${c.bold('dev_server.enabled')} is set to ${c.bold('false')}, ${hint}`))
}

if (!serverConfig.entrypoints.paths?.length) {
server.config.logger.info(c.red(` ${c.red('➜')} ${c.bold('entrypoints.paths')} is empty, no assets will be served and the production build will fail`))
}
}, 10)
})
},
}
}


/**
* Reads the configuration from the `php artisan vite:config` command.
*/
Expand Down
2 changes: 2 additions & 0 deletions vite-plugin-laravel/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,11 @@ export interface ViteConfiguration {
}
build_path: string
dev_server: {
enabled: boolean
url: string
cert?: string
key?: string
build_path: string
}
commands?: CommandsConfiguration
env_prefixes?: string[]
Expand Down

0 comments on commit c78c1d5

Please # to comment.