Skip to content

Commit d2bb82a

Browse files
authored
Merge pull request #239 from AthennaIO/develop
feat(command): improve integration with vite
2 parents 42066a3 + 9acc468 commit d2bb82a

4 files changed

Lines changed: 19 additions & 30 deletions

File tree

package-lock.json

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@athenna/core",
3-
"version": "5.4.0",
3+
"version": "5.5.0",
44
"description": "One foundation for multiple applications.",
55
"license": "MIT",
66
"author": "João Lenon <lenon@athenna.io>",

src/commands/BuildCommand.ts

Lines changed: 11 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@
99

1010
import { rimraf } from 'rimraf'
1111
import { tsc } from '@athenna/tsconfig/tsc'
12+
import { Path, Color } from '@athenna/common'
1213
import { isAbsolute, join, parse } from 'node:path'
13-
import { Path, Color, Module } from '@athenna/common'
1414
import { BaseCommand, Option } from '@athenna/artisan'
1515
import { copyfiles } from '@athenna/tsconfig/copyfiles'
1616
import { UndefinedOutDirException } from '#src/exceptions/UndefinedOutDirException'
@@ -61,15 +61,8 @@ export class BuildCommand extends BaseCommand {
6161
() => tsc(tsConfigPath)
6262
)
6363

64-
if (include.length) {
65-
tasks.addPromise(
66-
`Copying included paths to ${outDirName} folder: ${includedPaths}`,
67-
() => copyfiles(include, outDir)
68-
)
69-
}
70-
7164
if (this.vite) {
72-
const vite = this.getVite()
65+
const vite = await this.getVite()
7366

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

77+
if (include.length) {
78+
tasks.addPromise(
79+
`Copying included paths to ${outDirName} folder: ${includedPaths}`,
80+
() => copyfiles(include, outDir)
81+
)
82+
}
83+
8484
await tasks.run()
8585

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

108-
public getVite() {
109-
const require = Module.createRequire(import.meta.url)
110-
111-
return require('vite')
108+
public async getVite() {
109+
return import('vite')
112110
}
113111

114112
public async getViteConfig(vite: any) {

src/commands/ServeCommand.ts

Lines changed: 5 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,7 @@ import { BaseCommand, Option } from '@athenna/artisan'
1515
export class ServeCommand extends BaseCommand {
1616
@Option({
1717
signature: '-w, --watch',
18-
description:
19-
'Use nodemon to watch the application and restart on changes (also turn on vite --watch if using it).',
18+
description: 'Use nodemon to watch the application and restart on changes.',
2019
default: false
2120
})
2221
public watch: boolean
@@ -131,24 +130,16 @@ export class ServeCommand extends BaseCommand {
131130
await Module.resolve(entrypoint, Config.get('rc.parentURL'))
132131
}
133132

134-
public getVite() {
135-
const require = Module.createRequire(import.meta.url)
136-
137-
return require('vite')
138-
}
139-
140-
public getVitePluginRestart() {
141-
const require = Module.createRequire(import.meta.url)
142-
143-
return require('vite-plugin-restart')
144-
}
145-
146133
public getNodemon() {
147134
const require = Module.createRequire(import.meta.url)
148135

149136
return require('nodemon')
150137
}
151138

139+
public async getVite() {
140+
return import('vite')
141+
}
142+
152143
public async getViteConfig(vite: any) {
153144
const defaultConfig = {
154145
root: Path.pwd(),

0 commit comments

Comments
 (0)