mirror of
https://github.com/jxnblk/mdx-deck.git
synced 2024-09-11 06:35:24 +03:00
Adjust export package and copy public dir on build
This commit is contained in:
parent
2bed807e8e
commit
85876c54e2
@ -35,7 +35,7 @@ const cli = meow(
|
||||
port: {
|
||||
type: 'string',
|
||||
alias: 'p',
|
||||
default: 8080,
|
||||
default: '8000',
|
||||
},
|
||||
width: {
|
||||
type: 'string',
|
||||
|
@ -1,25 +1,24 @@
|
||||
const path = require('path')
|
||||
const puppeteer = require('puppeteer')
|
||||
const execa = require('execa')
|
||||
const mkdirp = require('mkdirp')
|
||||
const dev = require('mdx-deck/lib/dev')
|
||||
const findup = require('find-up')
|
||||
|
||||
module.exports = async opts => {
|
||||
const { type, outDir, outFile, port, width, height, sandbox } = opts
|
||||
const { input, type, outDir, outFile, port, width, height, sandbox } = opts
|
||||
|
||||
const args = []
|
||||
if (!sandbox) {
|
||||
args.push('--no-sandbox', '--disable-setuid-sandbox')
|
||||
}
|
||||
|
||||
if (opts.webpack) {
|
||||
opts.webpack = require(path.resolve(opts.webpack))
|
||||
} else {
|
||||
const webpackConfig = findup.sync('webpack.config.js', { cwd: opts.dirname })
|
||||
if (webpackConfig) opts.webpack = require(webpackConfig)
|
||||
}
|
||||
const server = execa('mdx-deck', [input, '--no-open', '--port', port], {
|
||||
stdio: 'inherit',
|
||||
preferLocal: true,
|
||||
})
|
||||
|
||||
const server = await dev(opts)
|
||||
server.on('message', msg => {
|
||||
console.log('server', msg)
|
||||
})
|
||||
|
||||
const browser = await puppeteer.launch({ args })
|
||||
const page = await browser.newPage()
|
||||
@ -29,6 +28,7 @@ module.exports = async opts => {
|
||||
)
|
||||
mkdirp.sync(outDir)
|
||||
|
||||
/*
|
||||
switch (type) {
|
||||
case 'pdf':
|
||||
const url = `http://localhost:${port}/print`
|
||||
@ -42,6 +42,7 @@ module.exports = async opts => {
|
||||
scale: 1,
|
||||
printBackground: true,
|
||||
})
|
||||
loading = false
|
||||
break
|
||||
case 'png':
|
||||
await page.setViewport({ width, height })
|
||||
@ -58,11 +59,17 @@ module.exports = async opts => {
|
||||
height,
|
||||
},
|
||||
})
|
||||
loading = false
|
||||
break
|
||||
}
|
||||
|
||||
await browser.close()
|
||||
await server.close()
|
||||
*/
|
||||
// await server.close()
|
||||
|
||||
return new Promise((resolve, reject) => {
|
||||
///
|
||||
})
|
||||
|
||||
return filename
|
||||
}
|
||||
|
@ -12,6 +12,7 @@
|
||||
"png": "./cli.js png ../../docs/demo.mdx -d ../../docs/dist"
|
||||
},
|
||||
"dependencies": {
|
||||
"execa": "^2.0.3",
|
||||
"mdx-deck": "^2.5.0",
|
||||
"meow": "^5.0.0",
|
||||
"mkdirp": "^0.5.1",
|
||||
|
@ -3,6 +3,7 @@ const path = require('path')
|
||||
const meow = require('meow')
|
||||
const execa = require('execa')
|
||||
const chalk = require('chalk')
|
||||
const fs = require('fs-extra')
|
||||
const pkg = require('./package.json')
|
||||
|
||||
const log = (...args) => {
|
||||
@ -87,7 +88,12 @@ const gatsby = async (...args) => {
|
||||
|
||||
switch (cmd) {
|
||||
case 'build':
|
||||
gatsby('build')
|
||||
gatsby('build').then(() => {
|
||||
const public = path.join(__dirname, 'public')
|
||||
const dist = path.join(process.cwd(), 'public')
|
||||
if (public === dist) return
|
||||
fs.copySync(public, dist)
|
||||
})
|
||||
break
|
||||
case 'eject':
|
||||
log('ejecting Gatsby site')
|
||||
|
Loading…
Reference in New Issue
Block a user