mirror of
https://github.com/nuxt/nuxt.git
synced 2024-11-23 14:15:13 +00:00
update comments
This commit is contained in:
parent
2ae761d2e7
commit
23f5ef5306
@ -91,9 +91,7 @@ exports.options = 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'))) {
|
||||
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('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 mkdirp(r(this.dir, '.nuxt/components'))
|
||||
if (!this.dev) {
|
||||
@ -114,10 +110,12 @@ exports.build = function * () {
|
||||
}
|
||||
// Generate routes and interpret the template files
|
||||
yield generateRoutesAndFiles.call(this)
|
||||
/*
|
||||
** Generate .nuxt/dist/ files
|
||||
*/
|
||||
/* istanbul ignore if */
|
||||
// Generate .nuxt/dist/ files
|
||||
yield buildFiles.call(this)
|
||||
return this
|
||||
}
|
||||
|
||||
function * buildFiles () {
|
||||
if (this.dev) {
|
||||
debug('Adding webpack middlewares...')
|
||||
createWebpackMiddlewares.call(this)
|
||||
@ -130,21 +128,16 @@ exports.build = function * () {
|
||||
webpackRunServer.call(this)
|
||||
]
|
||||
}
|
||||
return this
|
||||
}
|
||||
|
||||
function * generateRoutesAndFiles () {
|
||||
debug('Generating routes...')
|
||||
/*
|
||||
** Generate routes based on files
|
||||
*/
|
||||
// Generate routes based on files
|
||||
const files = yield glob('pages/**/*.vue', { cwd: this.srcDir })
|
||||
this.routes = _.uniq(_.map(files, (file) => {
|
||||
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...')
|
||||
let templatesFiles = [
|
||||
'App.vue',
|
||||
@ -179,9 +172,6 @@ function * generateRoutesAndFiles () {
|
||||
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
|
||||
templateVars.router.routes = createRoutes(files, this.srcDir)
|
||||
if (fs.existsSync(join(this.srcDir, 'layouts', 'app.vue'))) {
|
||||
@ -256,7 +246,6 @@ function getWebpackServerConfig () {
|
||||
return serverWebpackConfig.call(this)
|
||||
}
|
||||
|
||||
/* istanbul ignore next */
|
||||
function createWebpackMiddlewares () {
|
||||
const clientConfig = getWebpackClientConfig.call(this)
|
||||
// setup on the fly compilation + hot-reload
|
||||
@ -279,7 +268,6 @@ function createWebpackMiddlewares () {
|
||||
this.webpackHotMiddleware = pify(require('webpack-hot-middleware')(clientCompiler))
|
||||
}
|
||||
|
||||
/* istanbul ignore next */
|
||||
function webpackWatchAndUpdate () {
|
||||
const MFS = require('memory-fs') // <- dependencies of webpack
|
||||
const mfs = new MFS()
|
||||
@ -342,13 +330,12 @@ function createRenderer (bundle) {
|
||||
this.renderToStream = this.renderer.renderToStream
|
||||
}
|
||||
|
||||
/* istanbul ignore next */
|
||||
function watchPages () {
|
||||
const patterns = [ r(this.srcDir, 'pages/*.vue'), r(this.srcDir, 'pages/**/*.vue') ]
|
||||
const options = {
|
||||
// ignored: '**/_*.vue',
|
||||
ignoreInitial: true
|
||||
}
|
||||
/* istanbul ignore next */
|
||||
const refreshFiles = _.debounce(() => {
|
||||
var d = Date.now()
|
||||
co(generateRoutesAndFiles.bind(this))
|
||||
|
Loading…
Reference in New Issue
Block a user