-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(@kkt/ssr):新增proxySetup参数,修复css名称问题 & 修复页面二次刷新问题 (#21)
feat(@kkt/ssr):新增proxySetup参数,修复css名称问题 fix(@kkt/react-ssr-enhanced): 修复页面二次刷新问题 (#21)
- Loading branch information
Showing
30 changed files
with
261 additions
and
84 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
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
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,41 @@ | ||
|
||
|
||
import createCompiler from "./utils" | ||
import { OptionsProps } from "../interface" | ||
import { webpackConfigPath, reactScripts, reactDevUtils } from "./../overrides/pathUtils" | ||
import overridesDevServer from "./utils/overridesDevServer" | ||
const { choosePort } = require('react-dev-utils/WebpackDevServerUtils'); | ||
|
||
// Tools like Cloud9 rely on this. | ||
const DEFAULT_PORT = parseInt(process.env.PORT, 10) || 3000; | ||
const HOST = process.env.HOST || 'localhost'; | ||
|
||
export default async (options: OptionsProps) => { | ||
|
||
const PORT = await choosePort(HOST, DEFAULT_PORT); | ||
process.env.PORT = PORT | ||
process.env.HOST = HOST; | ||
|
||
try { | ||
const { overrides, config } = await createCompiler("development", options, true) | ||
const openBrowserPath = `${reactDevUtils}/openBrowser`; | ||
|
||
require(openBrowserPath); | ||
// override config in memory | ||
require.cache[require.resolve(openBrowserPath)].exports = () => { }; | ||
|
||
require.cache[require.resolve(webpackConfigPath)].exports = (env: string) => config; | ||
|
||
await overridesDevServer(overrides) | ||
|
||
require(`${reactScripts}/scripts/start`); | ||
|
||
} | ||
catch (error) { | ||
const message = error && error.message ? error.message : ''; | ||
console.log('\x1b[31;1m KKT-SSR:START:ERROR: \x1b[0m\n', error); | ||
new Error(`KKT-SSR:START:ERROR: \n ${message}`); | ||
process.exit(1); | ||
} | ||
|
||
} |
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
Oops, something went wrong.