mirror of
https://github.com/nuxt/nuxt.git
synced 2025-02-07 09:22:27 +00:00
improve spinner
This commit is contained in:
parent
1080dfdbd6
commit
f2b3e780e0
@ -12,12 +12,11 @@ const webpackDevMiddleware = require('webpack-dev-middleware')
|
|||||||
const webpackHotMiddleware = require('webpack-hot-middleware')
|
const webpackHotMiddleware = require('webpack-hot-middleware')
|
||||||
const Debug = require('debug')
|
const Debug = require('debug')
|
||||||
const Glob = require('glob')
|
const Glob = require('glob')
|
||||||
const { r, wp, wChunk, createRoutes, parallel, relativeTo, waitFor } = require('../common/utils')
|
const { r, wp, wChunk, createRoutes, parallel, relativeTo, waitFor, createSpinner } = require('../common/utils')
|
||||||
const { Options } = require('../common')
|
const { Options } = require('../common')
|
||||||
const clientWebpackConfig = require('./webpack/client.config.js')
|
const clientWebpackConfig = require('./webpack/client.config.js')
|
||||||
const serverWebpackConfig = require('./webpack/server.config.js')
|
const serverWebpackConfig = require('./webpack/server.config.js')
|
||||||
const upath = require('upath')
|
const upath = require('upath')
|
||||||
const ORA = require('ora')
|
|
||||||
|
|
||||||
const debug = Debug('nuxt:build')
|
const debug = Debug('nuxt:build')
|
||||||
debug.color = 2 // Force green color
|
debug.color = 2 // Force green color
|
||||||
@ -37,8 +36,7 @@ module.exports = class Builder {
|
|||||||
this.webpackHotMiddleware = null
|
this.webpackHotMiddleware = null
|
||||||
this.filesWatcher = null
|
this.filesWatcher = null
|
||||||
this.customFilesWatcher = null
|
this.customFilesWatcher = null
|
||||||
this.spinner = new ORA()
|
this.spinner = createSpinner()
|
||||||
this.spinner.color = 'green'
|
|
||||||
|
|
||||||
// Mute stats on dev
|
// Mute stats on dev
|
||||||
this.webpackStats = this.options.dev ? false : this.options.build.stats
|
this.webpackStats = this.options.dev ? false : this.options.build.stats
|
||||||
@ -120,6 +118,8 @@ module.exports = class Builder {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
this.spinner.succeed('Builder initialized')
|
||||||
|
|
||||||
this.spinner.start(`Generating nuxt files...`)
|
this.spinner.start(`Generating nuxt files...`)
|
||||||
|
|
||||||
debug(`App root: ${this.options.srcDir}`)
|
debug(`App root: ${this.options.srcDir}`)
|
||||||
@ -134,6 +134,8 @@ module.exports = class Builder {
|
|||||||
// Generate routes and interpret the template files
|
// Generate routes and interpret the template files
|
||||||
await this.generateRoutesAndFiles()
|
await this.generateRoutesAndFiles()
|
||||||
|
|
||||||
|
this.spinner.succeed('Nuxt files generated')
|
||||||
|
|
||||||
this.spinner.start('Compiling...')
|
this.spinner.start('Compiling...')
|
||||||
|
|
||||||
// Start webpack build
|
// Start webpack build
|
||||||
|
@ -10,8 +10,7 @@ const _ = require('lodash')
|
|||||||
const { resolve, join, dirname, sep } = require('path')
|
const { resolve, join, dirname, sep } = require('path')
|
||||||
const { minify } = require('html-minifier')
|
const { minify } = require('html-minifier')
|
||||||
const Chalk = require('chalk')
|
const Chalk = require('chalk')
|
||||||
const ORA = require('ora')
|
const { printWarn, createSpinner } = require('../common/utils')
|
||||||
const { printWarn } = require('../common/utils')
|
|
||||||
|
|
||||||
const {
|
const {
|
||||||
isUrl,
|
isUrl,
|
||||||
@ -36,7 +35,7 @@ module.exports = class Generator {
|
|||||||
isUrl(this.options.build.publicPath) ? '' : this.options.build.publicPath
|
isUrl(this.options.build.publicPath) ? '' : this.options.build.publicPath
|
||||||
)
|
)
|
||||||
|
|
||||||
this.spinner = new ORA()
|
this.spinner = createSpinner()
|
||||||
}
|
}
|
||||||
|
|
||||||
async generate({ build = true, init = true } = {}) {
|
async generate({ build = true, init = true } = {}) {
|
||||||
|
@ -136,7 +136,7 @@ module.exports = function webpackBaseConfig({ name, isServer }) {
|
|||||||
config.plugins.push(new ProgressPlugin({
|
config.plugins.push(new ProgressPlugin({
|
||||||
spinner: this.spinner,
|
spinner: this.spinner,
|
||||||
name: isServer ? 'server' : 'client',
|
name: isServer ? 'server' : 'client',
|
||||||
color: isServer ? 'orange' : 'green'
|
color: isServer ? 'green' : 'darkgreen'
|
||||||
}))
|
}))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2,6 +2,7 @@ const { resolve, relative, sep } = require('path')
|
|||||||
const _ = require('lodash')
|
const _ = require('lodash')
|
||||||
const PrettyError = require('pretty-error')
|
const PrettyError = require('pretty-error')
|
||||||
const Chalk = require('chalk')
|
const Chalk = require('chalk')
|
||||||
|
const ORA = require('ora')
|
||||||
|
|
||||||
exports.pe = new PrettyError()
|
exports.pe = new PrettyError()
|
||||||
|
|
||||||
@ -28,6 +29,14 @@ exports.fatalError = function () {
|
|||||||
process.exit(1)
|
process.exit(1)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
exports.createSpinner = function () {
|
||||||
|
return new ORA({
|
||||||
|
color: 'green',
|
||||||
|
spinner: 'clock',
|
||||||
|
interval: 50
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
exports.encodeHtml = function encodeHtml(str) {
|
exports.encodeHtml = function encodeHtml(str) {
|
||||||
return str.replace(/</g, '<').replace(/>/g, '>')
|
return str.replace(/</g, '<').replace(/>/g, '>')
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user