mirror of
https://github.com/jxnblk/mdx-deck.git
synced 2024-11-29 13:58:02 +03:00
Merge pull request #295 from pengx17/non-ssr-build
build: add non-ssr-build
This commit is contained in:
commit
0da19c3a01
@ -293,6 +293,7 @@ See more exporting options in the [Exporting Documentation](docs/exporting.md)
|
||||
--no-open Prevent from opening in default browser
|
||||
-d --out-dir Output directory for exporting
|
||||
--webpack Path to custom webpack config file
|
||||
--no-html Disable static HTML rendering
|
||||
```
|
||||
|
||||
## Docs
|
||||
|
@ -22,7 +22,7 @@ const cli = meow(
|
||||
$ ${chalk.green('mdx-deck deck.mdx')}
|
||||
|
||||
$ ${chalk.green('mdx-deck build deck.mdx')}
|
||||
|
||||
|
||||
${chalk.gray('Options')}
|
||||
|
||||
-h --host Dev server host
|
||||
@ -30,6 +30,7 @@ const cli = meow(
|
||||
--no-open Prevent from opening in default browser
|
||||
--webpack Path to webpack config file
|
||||
-d --out-dir Output directory for exporting
|
||||
--no-html Disable static HTML rendering for build
|
||||
|
||||
`,
|
||||
{
|
||||
@ -55,6 +56,10 @@ const cli = meow(
|
||||
webpack: {
|
||||
type: 'string',
|
||||
},
|
||||
html: {
|
||||
type: 'boolean',
|
||||
default: true,
|
||||
},
|
||||
},
|
||||
}
|
||||
)
|
||||
|
@ -52,23 +52,27 @@ const renderHTML = async App => {
|
||||
const build = async (opts = {}) => {
|
||||
const config = createConfig(opts)
|
||||
|
||||
const App = await getApp(config, opts)
|
||||
const { body, head } = await renderHTML(App)
|
||||
|
||||
config.mode = 'production'
|
||||
config.output = {
|
||||
// Allow user to override this in his custom webpack config
|
||||
...config.output,
|
||||
path: opts.outDir,
|
||||
}
|
||||
|
||||
config.plugins.push(
|
||||
new HTMLPlugin({
|
||||
context: { head },
|
||||
}),
|
||||
new HTMLPlugin({
|
||||
filename: '404.html',
|
||||
context: { head },
|
||||
})
|
||||
)
|
||||
if (opts.html) {
|
||||
const App = await getApp(config, opts)
|
||||
const { body, head } = await renderHTML(App)
|
||||
|
||||
config.plugins.push(
|
||||
new HTMLPlugin({
|
||||
context: { head },
|
||||
}),
|
||||
new HTMLPlugin({
|
||||
filename: '404.html',
|
||||
context: { head },
|
||||
})
|
||||
)
|
||||
}
|
||||
|
||||
const compiler = webpack(config)
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user