remove SSR related files from generate artifacts

This commit is contained in:
Pooya Parsa 2017-08-18 16:14:47 +04:30
parent c5a5dac627
commit fbb6833400

View File

@ -1,5 +1,4 @@
import fs from 'fs'
import { copy, remove, writeFile, mkdirp } from 'fs-extra'
import { copy, remove, writeFile, mkdirp, removeSync, existsSync } from 'fs-extra'
import _ from 'lodash'
import { resolve, join, dirname, sep } from 'path'
import { minify } from 'html-minifier'
@ -99,7 +98,7 @@ export default class Generator extends Tapable {
// Copy static and built files
/* istanbul ignore if */
if (fs.existsSync(this.generateRoutes)) {
if (existsSync(this.generateRoutes)) {
await copy(this.generateRoutes, this.distPath)
}
await copy(this.srcBuiltPath, this.distNuxtPath)
@ -109,6 +108,20 @@ export default class Generator extends Tapable {
const nojekyllPath = resolve(this.distPath, '.nojekyll')
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')
}