Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
const createServerConfig = require('./webpack/createServerConfig')
const { createBundleRenderer } = require('vue-server-renderer')
const { normalizeHeadTag, applyUserWebpackConfig } = require('./util/index')
logger.wait('\nExtracting site metadata...')
const options = await prepare(sourceDir, cliOptions, true /* isProd */)
if (cliOptions.outDir) {
options.outDir = cliOptions.outDir
}
const { outDir } = options
if (process.cwd() === outDir) {
return console.error(logger.error(chalk.red('Unexpected option: outDir cannot be set to the current working directory.\n'), false))
}
await fs.remove(outDir)
logger.debug('Dist directory: ' + chalk.gray(require('path').resolve(process.cwd(), outDir)))
let clientConfig = createClientConfig(options, cliOptions).toConfig()
let serverConfig = createServerConfig(options, cliOptions).toConfig()
// apply user config...
const userConfig = options.siteConfig.configureWebpack
if (userConfig) {
clientConfig = applyUserWebpackConfig(userConfig, clientConfig, false)
serverConfig = applyUserWebpackConfig(userConfig, serverConfig, true)
}
// compile!
const stats = await compile([clientConfig, serverConfig])
const serverBundle = require(path.resolve(outDir, 'manifest/server.json'))
const clientManifest = require(path.resolve(outDir, 'manifest/client.json'))
if (hasDefaultExport(content)) {
destPath = await writeEnhancer(
moduleId++,
`export { default } from ${JSON.stringify(enhanceAppFile)}`
)
} else {
destPath = await writeEnhancer(
moduleId++,
`import ${JSON.stringify(enhanceAppFile)}`,
false /* do not contain default export*/
)
}
} else {
logger.developer(
chalk.gray(`[${pluginName}] `) +
`${chalk.cyan(enhanceAppFile)} Not Found.`
)
}
}
if (destPath) {
manifest.push(destPath)
}
}
// 2. write entry file.
await ctx.writeTemp('internal/app-enhancers.js', pathsToModuleCode(manifest))
}
}
compiler.hooks.done.tap('vuepress-log', stats => {
if (shouldClearScreen) {
clearScreen()
}
const time = new Date().toTimeString().match(/^[\d:]+/)[0]
const displayUrl = `http://${displayHost}:${port}${publicPath}`
logger.success(
`${chalk.gray(`[${time}]`)} Build ${chalk.italic(stats.hash.slice(0, 6))} `
+ `finished in ${stats.endTime - stats.startTime} ms! `
+ (
isFirst
? ''
: `${chalk.gray(`(${displayUrl})`)}`
)
)
if (isFirst) {
isFirst = false
console.log(`${chalk.gray('>')} VuePress dev server listening at ${chalk.cyan(displayUrl)}`)
const { duration } = performance.stop()
logger.developer(`It took a total of ${chalk.cyan(`${duration}ms`)} to run the ${chalk.cyan('vuepress dev')} for the first time.`)
}
})
if (shouldClearScreen) {
siteAgreement: 'templates/dev.html',
themeAgreement: 'templates/dev.html'
}
)
this.ssrTemplate = this.resolveCommonAgreementFilePath(
'ssrTemplate',
{
defaultValue: this.getLibFilePath('client/index.ssr.html'),
siteAgreement: 'templates/ssr.html',
themeAgreement: 'templates/ssr.html'
}
)
logger.debug('SSR Template File: ' + chalk.gray(this.ssrTemplate))
logger.debug('DEV Template File: ' + chalk.gray(this.devTemplate))
}
this._pluginQueue.forEach(plugin => {
if (plugin.enabled) {
this.applyPlugin(plugin)
} else {
logger.debug(`${chalk.gray(`[${plugin.name}]`)} disabled.`)
}
})
}
defaultValue: this.getLibFilePath('client/index.dev.html'),
siteAgreement: 'templates/dev.html',
themeAgreement: 'templates/dev.html'
}
)
this.ssrTemplate = this.resolveCommonAgreementFilePath(
'ssrTemplate',
{
defaultValue: this.getLibFilePath('client/index.ssr.html'),
siteAgreement: 'templates/ssr.html',
themeAgreement: 'templates/ssr.html'
}
)
logger.debug('SSR Template File: ' + chalk.gray(this.ssrTemplate))
logger.debug('DEV Template File: ' + chalk.gray(this.devTemplate))
}