mirror of
https://github.com/nuxt/nuxt.git
synced 2024-12-11 14:57:15 +00:00
remove SSR related files from generate artifacts
This commit is contained in:
parent
c5a5dac627
commit
fbb6833400
@ -1,5 +1,4 @@
|
|||||||
import fs from 'fs'
|
import { copy, remove, writeFile, mkdirp, removeSync, existsSync } from 'fs-extra'
|
||||||
import { copy, remove, writeFile, mkdirp } from 'fs-extra'
|
|
||||||
import _ from 'lodash'
|
import _ from 'lodash'
|
||||||
import { resolve, join, dirname, sep } from 'path'
|
import { resolve, join, dirname, sep } from 'path'
|
||||||
import { minify } from 'html-minifier'
|
import { minify } from 'html-minifier'
|
||||||
@ -49,7 +48,7 @@ export default class Generator extends Tapable {
|
|||||||
try {
|
try {
|
||||||
console.log('Generating routes') // eslint-disable-line no-console
|
console.log('Generating routes') // eslint-disable-line no-console
|
||||||
generateRoutes = await promisifyRoute(this.options.generate.routes || [])
|
generateRoutes = await promisifyRoute(this.options.generate.routes || [])
|
||||||
await this.applyPluginsAsync('generateRoutes', {generator: this, generateRoutes})
|
await this.applyPluginsAsync('generateRoutes', { generator: this, generateRoutes })
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
console.error('Could not resolve routes') // eslint-disable-line no-console
|
console.error('Could not resolve routes') // eslint-disable-line no-console
|
||||||
console.error(e) // eslint-disable-line no-console
|
console.error(e) // eslint-disable-line no-console
|
||||||
@ -61,14 +60,14 @@ export default class Generator extends Tapable {
|
|||||||
let routes = (this.options.router.mode === 'hash') ? ['/'] : flatRoutes(this.options.router.routes)
|
let routes = (this.options.router.mode === 'hash') ? ['/'] : flatRoutes(this.options.router.routes)
|
||||||
routes = this.decorateWithPayloads(routes, generateRoutes)
|
routes = this.decorateWithPayloads(routes, generateRoutes)
|
||||||
|
|
||||||
await this.applyPluginsAsync('generate', {generator: this, routes})
|
await this.applyPluginsAsync('generate', { generator: this, routes })
|
||||||
|
|
||||||
// Start generate process
|
// Start generate process
|
||||||
while (routes.length) {
|
while (routes.length) {
|
||||||
let n = 0
|
let n = 0
|
||||||
await Promise.all(routes.splice(0, this.options.generate.concurrency).map(async ({ route, payload }) => {
|
await Promise.all(routes.splice(0, this.options.generate.concurrency).map(async ({ route, payload }) => {
|
||||||
await waitFor(n++ * this.options.generate.interval)
|
await waitFor(n++ * this.options.generate.interval)
|
||||||
await this.generateRoute({route, payload, errors})
|
await this.generateRoute({ route, payload, errors })
|
||||||
}))
|
}))
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -99,7 +98,7 @@ export default class Generator extends Tapable {
|
|||||||
|
|
||||||
// Copy static and built files
|
// Copy static and built files
|
||||||
/* istanbul ignore if */
|
/* istanbul ignore if */
|
||||||
if (fs.existsSync(this.generateRoutes)) {
|
if (existsSync(this.generateRoutes)) {
|
||||||
await copy(this.generateRoutes, this.distPath)
|
await copy(this.generateRoutes, this.distPath)
|
||||||
}
|
}
|
||||||
await copy(this.srcBuiltPath, this.distNuxtPath)
|
await copy(this.srcBuiltPath, this.distNuxtPath)
|
||||||
@ -109,6 +108,20 @@ export default class Generator extends Tapable {
|
|||||||
const nojekyllPath = resolve(this.distPath, '.nojekyll')
|
const nojekyllPath = resolve(this.distPath, '.nojekyll')
|
||||||
writeFile(nojekyllPath, '')
|
writeFile(nojekyllPath, '')
|
||||||
|
|
||||||
|
// Cleanup SSR related files
|
||||||
|
const extraFiles = [
|
||||||
|
'index.spa.html',
|
||||||
|
'index.ssr.html',
|
||||||
|
'server-bundle.json',
|
||||||
|
'vue-ssr-client-manifest.json'
|
||||||
|
].map(file => resolve(this.distNuxtPath, file))
|
||||||
|
|
||||||
|
extraFiles.forEach(file => {
|
||||||
|
if (existsSync(file)) {
|
||||||
|
removeSync(file)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
debug('Static & build files copied')
|
debug('Static & build files copied')
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -133,7 +146,7 @@ export default class Generator extends Tapable {
|
|||||||
return _.values(routeMap)
|
return _.values(routeMap)
|
||||||
}
|
}
|
||||||
|
|
||||||
async generateRoute ({route, payload = {}, errors = []}) {
|
async generateRoute ({ route, payload = {}, errors = [] }) {
|
||||||
let html
|
let html
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
Loading…
Reference in New Issue
Block a user