-
-
Notifications
You must be signed in to change notification settings - Fork 643
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: build assets when starting dev server and building assets
- Loading branch information
1 parent
a8864e9
commit c72034d
Showing
5 changed files
with
147 additions
and
88 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
/* | ||
* @adonisjs/core | ||
* | ||
* (c) AdonisJS | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
*/ | ||
|
||
import fs from 'fs-extra' | ||
import { ApplicationService } from './types.js' | ||
|
||
/** | ||
* Imports assembler optionally | ||
*/ | ||
export async function importAssembler( | ||
app: ApplicationService | ||
): Promise<typeof import('@adonisjs/assembler') | undefined> { | ||
try { | ||
return await app.import('@adonisjs/assembler') | ||
} catch {} | ||
} | ||
|
||
/** | ||
* Imports typescript optionally | ||
*/ | ||
export async function importTypeScript( | ||
app: ApplicationService | ||
): Promise<typeof import('typescript') | undefined> { | ||
try { | ||
return await app.importDefault('typescript') | ||
} catch {} | ||
} | ||
|
||
/** | ||
* Detects the assets bundler in use. The rcFile.assetsBundler is | ||
* used when exists. | ||
*/ | ||
export async function detectAssetsBundler(app: ApplicationService) { | ||
if (app.rcFile.assetsBundler) { | ||
return app.rcFile.assetsBundler | ||
} | ||
|
||
if (await fs.exists(app.makePath('vite.config.js'))) { | ||
return { | ||
name: 'vite', | ||
devServerCommand: 'vite', | ||
buildCommand: 'vite build', | ||
} | ||
} | ||
|
||
if (await fs.exists(app.makePath('webpack.config.js'))) { | ||
return { | ||
name: 'encore', | ||
devServerCommand: 'encore dev-server', | ||
buildCommand: 'encore', | ||
} | ||
} | ||
} |