Skip to content

Commit

Permalink
Merge pull request #239 from AthennaIO/develop
Browse files Browse the repository at this point in the history
feat(command): improve integration with vite
  • Loading branch information
jlenon7 authored Dec 28, 2024
2 parents 42066a3 + 9acc468 commit d2bb82a
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 30 deletions.
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@athenna/core",
"version": "5.4.0",
"version": "5.5.0",
"description": "One foundation for multiple applications.",
"license": "MIT",
"author": "João Lenon <[email protected]>",
Expand Down
24 changes: 11 additions & 13 deletions src/commands/BuildCommand.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@

import { rimraf } from 'rimraf'
import { tsc } from '@athenna/tsconfig/tsc'
import { Path, Color } from '@athenna/common'
import { isAbsolute, join, parse } from 'node:path'
import { Path, Color, Module } from '@athenna/common'
import { BaseCommand, Option } from '@athenna/artisan'
import { copyfiles } from '@athenna/tsconfig/copyfiles'
import { UndefinedOutDirException } from '#src/exceptions/UndefinedOutDirException'
Expand Down Expand Up @@ -61,15 +61,8 @@ export class BuildCommand extends BaseCommand {
() => tsc(tsConfigPath)
)

if (include.length) {
tasks.addPromise(
`Copying included paths to ${outDirName} folder: ${includedPaths}`,
() => copyfiles(include, outDir)
)
}

if (this.vite) {
const vite = this.getVite()
const vite = await this.getVite()

tasks.addPromise(
`Compiling static files using ${Color.yellow.bold('vite')}`,
Expand All @@ -81,6 +74,13 @@ export class BuildCommand extends BaseCommand {
)
}

if (include.length) {
tasks.addPromise(
`Copying included paths to ${outDirName} folder: ${includedPaths}`,
() => copyfiles(include, outDir)
)
}

await tasks.run()

console.log()
Expand All @@ -105,10 +105,8 @@ export class BuildCommand extends BaseCommand {
return Path.pwd(Config.get('rc.commands.build.outDir'))
}

public getVite() {
const require = Module.createRequire(import.meta.url)

return require('vite')
public async getVite() {
return import('vite')
}

public async getViteConfig(vite: any) {
Expand Down
19 changes: 5 additions & 14 deletions src/commands/ServeCommand.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,7 @@ import { BaseCommand, Option } from '@athenna/artisan'
export class ServeCommand extends BaseCommand {
@Option({
signature: '-w, --watch',
description:
'Use nodemon to watch the application and restart on changes (also turn on vite --watch if using it).',
description: 'Use nodemon to watch the application and restart on changes.',
default: false
})
public watch: boolean
Expand Down Expand Up @@ -131,24 +130,16 @@ export class ServeCommand extends BaseCommand {
await Module.resolve(entrypoint, Config.get('rc.parentURL'))
}

public getVite() {
const require = Module.createRequire(import.meta.url)

return require('vite')
}

public getVitePluginRestart() {
const require = Module.createRequire(import.meta.url)

return require('vite-plugin-restart')
}

public getNodemon() {
const require = Module.createRequire(import.meta.url)

return require('nodemon')
}

public async getVite() {
return import('vite')
}

public async getViteConfig(vite: any) {
const defaultConfig = {
root: Path.pwd(),
Expand Down

0 comments on commit d2bb82a

Please sign in to comment.