mirror of
https://github.com/nuxt/nuxt.git
synced 2024-11-27 16:12:12 +00:00
update comments
This commit is contained in:
parent
2ae761d2e7
commit
23f5ef5306
@ -91,9 +91,7 @@ exports.options = function () {
|
|||||||
}
|
}
|
||||||
|
|
||||||
exports.build = function * () {
|
exports.build = function * () {
|
||||||
/*
|
// Check if pages dir exists and warn if not
|
||||||
** Check if pages dir exists and warn if not
|
|
||||||
*/
|
|
||||||
if (!fs.existsSync(join(this.srcDir, 'pages'))) {
|
if (!fs.existsSync(join(this.srcDir, 'pages'))) {
|
||||||
if (fs.existsSync(join(this.srcDir, '..', 'pages'))) {
|
if (fs.existsSync(join(this.srcDir, '..', 'pages'))) {
|
||||||
console.error('> No `pages` directory found. Did you mean to run `nuxt` in the parent (`../`) directory?') // eslint-disable-line no-console
|
console.error('> No `pages` directory found. Did you mean to run `nuxt` in the parent (`../`) directory?') // eslint-disable-line no-console
|
||||||
@ -104,9 +102,7 @@ exports.build = function * () {
|
|||||||
}
|
}
|
||||||
debug(`App root: ${this.srcDir}`)
|
debug(`App root: ${this.srcDir}`)
|
||||||
debug('Generating .nuxt/ files...')
|
debug('Generating .nuxt/ files...')
|
||||||
/*
|
// Create .nuxt/, .nuxt/components and .nuxt/dist folders
|
||||||
** Create .nuxt/, .nuxt/components and .nuxt/dist folders
|
|
||||||
*/
|
|
||||||
yield remove(r(this.dir, '.nuxt'))
|
yield remove(r(this.dir, '.nuxt'))
|
||||||
yield mkdirp(r(this.dir, '.nuxt/components'))
|
yield mkdirp(r(this.dir, '.nuxt/components'))
|
||||||
if (!this.dev) {
|
if (!this.dev) {
|
||||||
@ -114,10 +110,12 @@ exports.build = function * () {
|
|||||||
}
|
}
|
||||||
// Generate routes and interpret the template files
|
// Generate routes and interpret the template files
|
||||||
yield generateRoutesAndFiles.call(this)
|
yield generateRoutesAndFiles.call(this)
|
||||||
/*
|
// Generate .nuxt/dist/ files
|
||||||
** Generate .nuxt/dist/ files
|
yield buildFiles.call(this)
|
||||||
*/
|
return this
|
||||||
/* istanbul ignore if */
|
}
|
||||||
|
|
||||||
|
function * buildFiles () {
|
||||||
if (this.dev) {
|
if (this.dev) {
|
||||||
debug('Adding webpack middlewares...')
|
debug('Adding webpack middlewares...')
|
||||||
createWebpackMiddlewares.call(this)
|
createWebpackMiddlewares.call(this)
|
||||||
@ -130,21 +128,16 @@ exports.build = function * () {
|
|||||||
webpackRunServer.call(this)
|
webpackRunServer.call(this)
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
return this
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function * generateRoutesAndFiles () {
|
function * generateRoutesAndFiles () {
|
||||||
debug('Generating routes...')
|
debug('Generating routes...')
|
||||||
/*
|
// Generate routes based on files
|
||||||
** Generate routes based on files
|
|
||||||
*/
|
|
||||||
const files = yield glob('pages/**/*.vue', { cwd: this.srcDir })
|
const files = yield glob('pages/**/*.vue', { cwd: this.srcDir })
|
||||||
this.routes = _.uniq(_.map(files, (file) => {
|
this.routes = _.uniq(_.map(files, (file) => {
|
||||||
return file.replace(/^pages/, '').replace(/\.vue$/, '').replace(/\/index/g, '').replace(/_/g, ':').replace('', '/').replace(/\/{2,}/g, '/')
|
return file.replace(/^pages/, '').replace(/\.vue$/, '').replace(/\/index/g, '').replace(/_/g, ':').replace('', '/').replace(/\/{2,}/g, '/')
|
||||||
}))
|
}))
|
||||||
/*
|
// Interpret and move template files to .nuxt/
|
||||||
** Interpret and move template files to .nuxt/
|
|
||||||
*/
|
|
||||||
debug('Generating files...')
|
debug('Generating files...')
|
||||||
let templatesFiles = [
|
let templatesFiles = [
|
||||||
'App.vue',
|
'App.vue',
|
||||||
@ -179,9 +172,6 @@ function * generateRoutesAndFiles () {
|
|||||||
ErrorPage: r(__dirname, 'app', 'components', 'nuxt-error.vue')
|
ErrorPage: r(__dirname, 'app', 'components', 'nuxt-error.vue')
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (templateVars.loading === 'string' && templateVars.loading.slice(-4) !== '.vue') {
|
|
||||||
templateVars.loading = templateVars.loading + '.vue'
|
|
||||||
}
|
|
||||||
// Format routes for the lib/app/router.js template
|
// Format routes for the lib/app/router.js template
|
||||||
templateVars.router.routes = createRoutes(files, this.srcDir)
|
templateVars.router.routes = createRoutes(files, this.srcDir)
|
||||||
if (fs.existsSync(join(this.srcDir, 'layouts', 'app.vue'))) {
|
if (fs.existsSync(join(this.srcDir, 'layouts', 'app.vue'))) {
|
||||||
@ -256,7 +246,6 @@ function getWebpackServerConfig () {
|
|||||||
return serverWebpackConfig.call(this)
|
return serverWebpackConfig.call(this)
|
||||||
}
|
}
|
||||||
|
|
||||||
/* istanbul ignore next */
|
|
||||||
function createWebpackMiddlewares () {
|
function createWebpackMiddlewares () {
|
||||||
const clientConfig = getWebpackClientConfig.call(this)
|
const clientConfig = getWebpackClientConfig.call(this)
|
||||||
// setup on the fly compilation + hot-reload
|
// setup on the fly compilation + hot-reload
|
||||||
@ -279,7 +268,6 @@ function createWebpackMiddlewares () {
|
|||||||
this.webpackHotMiddleware = pify(require('webpack-hot-middleware')(clientCompiler))
|
this.webpackHotMiddleware = pify(require('webpack-hot-middleware')(clientCompiler))
|
||||||
}
|
}
|
||||||
|
|
||||||
/* istanbul ignore next */
|
|
||||||
function webpackWatchAndUpdate () {
|
function webpackWatchAndUpdate () {
|
||||||
const MFS = require('memory-fs') // <- dependencies of webpack
|
const MFS = require('memory-fs') // <- dependencies of webpack
|
||||||
const mfs = new MFS()
|
const mfs = new MFS()
|
||||||
@ -342,13 +330,12 @@ function createRenderer (bundle) {
|
|||||||
this.renderToStream = this.renderer.renderToStream
|
this.renderToStream = this.renderer.renderToStream
|
||||||
}
|
}
|
||||||
|
|
||||||
/* istanbul ignore next */
|
|
||||||
function watchPages () {
|
function watchPages () {
|
||||||
const patterns = [ r(this.srcDir, 'pages/*.vue'), r(this.srcDir, 'pages/**/*.vue') ]
|
const patterns = [ r(this.srcDir, 'pages/*.vue'), r(this.srcDir, 'pages/**/*.vue') ]
|
||||||
const options = {
|
const options = {
|
||||||
// ignored: '**/_*.vue',
|
|
||||||
ignoreInitial: true
|
ignoreInitial: true
|
||||||
}
|
}
|
||||||
|
/* istanbul ignore next */
|
||||||
const refreshFiles = _.debounce(() => {
|
const refreshFiles = _.debounce(() => {
|
||||||
var d = Date.now()
|
var d = Date.now()
|
||||||
co(generateRoutesAndFiles.bind(this))
|
co(generateRoutesAndFiles.bind(this))
|
||||||
|
Loading…
Reference in New Issue
Block a user