Skip to content

Add renderPages arg to run puppeteer with no sandbox #44

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions src/renderPages.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,17 +30,19 @@ const renderPages = async () => {
.alias('e', 'entry')
.describe('extra', 'Comma separated list of paths to render if they aren\'t automatically crawled')
.alias('x', 'extra')
.describe('no-sandbox', 'Do not run puppeteer in a sandbox')
.argv;

// Get command line arguments with defaults
const port = argv.port ? Number(argv.port) : 54321
const distFolder = argv.dist ? String(argv.dist) : 'dist'
const entryPoint = argv.entry ? String(argv.entry) : '/'
const extraPages = typeof argv.extra === 'string' ? argv.extra.split(',') : []
const puppeteerArgs = argv.sandbox === false ? [ '--no-sandbox' ] : []

try {

// Spin up a static server to use for prerendering with pupeteer
// Spin up a static server to use for prerendering with puppeteer
await createStaticServer(port, distFolder)

console.log('Rendering site...')
Expand All @@ -57,7 +59,7 @@ const renderPages = async () => {
...extraPages
]

const browser = await puppeteer.launch({ headless: true });
const browser = await puppeteer.launch({ headless: true, args: puppeteerArgs });
const page = await browser.newPage();

await page.setUserAgent('puppeteer');
Expand Down