-
Notifications
You must be signed in to change notification settings - Fork 26
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor: Replace imperative with the form of class.
- Loading branch information
wangyi
committed
May 2, 2020
1 parent
35e5930
commit a1abf4a
Showing
49 changed files
with
2,800 additions
and
2,712 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
8 changes: 4 additions & 4 deletions
8
packages/@rcpress/core/lib/node/__tests__/prepare/prepare.spec.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
'use strict'; | ||
|
||
/* | ||
* @author wangyi7099 | ||
*/ | ||
|
||
const webpack = require('webpack'); | ||
const fs = require('fs-extra'); | ||
const path = require('path'); | ||
|
||
module.exports = async function getPageRenderer(ssrConfig, spaConfig, options) { | ||
const { outDir } = options; | ||
const PageRender = require('../pageRender'); | ||
if (path.resolve() === 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); | ||
|
||
return await new Promise((resolve, reject) => { | ||
webpack([ssrConfig, spaConfig], async (err, stat) => { | ||
if (err) { | ||
reject(error); | ||
} | ||
|
||
const stats = stat.stats; | ||
resolve( | ||
new PageRender(stats[0].toJson(), { | ||
clientManifest: stats[1].toJson(), | ||
template: fs.readFileSync( | ||
path.resolve(__dirname, '../templates/index.ssr.html'), | ||
'utf-8' | ||
), | ||
outDir | ||
}) | ||
); | ||
}); | ||
}); | ||
}; |
Oops, something went wrong.