add basic nuxt build

This commit is contained in:
Pooya Parsa 2021-01-20 16:44:52 +01:00
parent 17160c31ed
commit 3d06693f88
2 changed files with 17 additions and 5 deletions

View File

@ -2,10 +2,21 @@ import { resolve } from 'path'
import { loadNuxt, build } from '.'
async function _main () {
const rootDir = resolve(process.cwd(), process.argv[2] || '.')
const nuxt = await loadNuxt({ for: 'dev', rootDir })
const [{ url }] = await nuxt.server.listen(3000)
console.log('Listening:', url)
const args = process.argv.splice(2)
const cmd = args[0]
if (!['dev', 'build'].includes(cmd)) {
console.error('Usage nuxt dev|build [rootDir]')
process.exit(1)
}
const isDev = cmd === 'dev'
const rootDir = resolve(process.cwd(), args[1] || '.')
const nuxt = await loadNuxt({ for: isDev ? 'dev' : 'build', rootDir })
if (isDev) {
const [{ url }] = await nuxt.server.listen(3000)
console.log('Listening:', url)
}
await build(nuxt)
}

View File

@ -79,8 +79,9 @@ function basePlugins (ctx: WebpackConfigContext) {
config.plugins.push(new WebpackBar({
name: ctx.name,
color: colors[ctx.name],
reporters: ['basic'],
reporters: ['basic', 'stats'],
basic: true,
stats: !ctx.isDev,
reporter: {
change: (_, { shortPath }) => {
if (!ctx.isServer) {