mirror of
https://github.com/facebook/docusaurus.git
synced 2025-05-10 23:57:22 +02:00
feat: custom pages (#994)
This commit is contained in:
parent
7d4d9fe961
commit
8691a2525c
25 changed files with 263 additions and 128 deletions
|
@ -83,42 +83,40 @@ module.exports = async function start(siteDir, cliOptions = {}) {
|
|||
const compiler = webpack(config);
|
||||
|
||||
// webpack-serve
|
||||
setTimeout(async () => {
|
||||
await serve(
|
||||
{},
|
||||
{
|
||||
compiler,
|
||||
open: true,
|
||||
devMiddleware: {
|
||||
logLevel: 'silent',
|
||||
},
|
||||
hotClient: {
|
||||
port: hotPort,
|
||||
logLevel: 'error',
|
||||
},
|
||||
logLevel: 'error',
|
||||
port,
|
||||
host,
|
||||
add: app => {
|
||||
// serve static files
|
||||
const staticDir = path.resolve(siteDir, 'static');
|
||||
if (fs.existsSync(staticDir)) {
|
||||
app.use(mount(baseUrl, serveStatic(staticDir)));
|
||||
}
|
||||
|
||||
// enable HTTP range requests
|
||||
app.use(range);
|
||||
|
||||
// rewrite request to `/` since dev is only a SPA
|
||||
app.use(
|
||||
convert(
|
||||
history({
|
||||
rewrites: [{from: /\.html$/, to: '/'}],
|
||||
}),
|
||||
),
|
||||
);
|
||||
},
|
||||
await serve(
|
||||
{},
|
||||
{
|
||||
compiler,
|
||||
open: true,
|
||||
devMiddleware: {
|
||||
logLevel: 'silent',
|
||||
},
|
||||
);
|
||||
}, 1000);
|
||||
hotClient: {
|
||||
port: hotPort,
|
||||
logLevel: 'error',
|
||||
},
|
||||
logLevel: 'error',
|
||||
port,
|
||||
host,
|
||||
add: app => {
|
||||
// serve static files
|
||||
const staticDir = path.resolve(siteDir, 'static');
|
||||
if (fs.existsSync(staticDir)) {
|
||||
app.use(mount(baseUrl, serveStatic(staticDir)));
|
||||
}
|
||||
|
||||
// enable HTTP range requests
|
||||
app.use(range);
|
||||
|
||||
// rewrite request to `/` since dev is only a SPA
|
||||
app.use(
|
||||
convert(
|
||||
history({
|
||||
rewrites: [{from: /\.html$/, to: '/'}],
|
||||
}),
|
||||
),
|
||||
);
|
||||
},
|
||||
},
|
||||
);
|
||||
};
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue