⚡ configure for static export to sub-directory
This commit is contained in:
parent
639aa27411
commit
357dc224ce
2
.gitignore
vendored
2
.gitignore
vendored
|
@ -32,3 +32,5 @@ yarn-error.log*
|
|||
|
||||
# vercel
|
||||
.vercel
|
||||
|
||||
/web-components-in-react
|
|
@ -25,7 +25,7 @@ export default function WebComponentLoader({
|
|||
// Add script tags to load the dependencies.
|
||||
wcToLoad.forEach((name) => {
|
||||
const scriptTag = document.createElement('script')
|
||||
scriptTag.src = `/${name}.js`
|
||||
scriptTag.src = `${process.env.NEXT_PUBLIC_BASE_PATH}/${name}.js`
|
||||
document.body.appendChild(scriptTag)
|
||||
})
|
||||
}, [])
|
||||
|
|
4
next.config.js
Normal file
4
next.config.js
Normal file
|
@ -0,0 +1,4 @@
|
|||
module.exports = {
|
||||
trailingSlash: true,
|
||||
basePath: '/project/web-components-in-react',
|
||||
}
|
|
@ -7,7 +7,8 @@
|
|||
"scripts": {
|
||||
"dev": "next dev",
|
||||
"build": "next build",
|
||||
"start": "next start"
|
||||
"start": "next start",
|
||||
"release": "NEXT_PUBLIC_BASE_PATH=/project/web-components-in-react next build && next export -o web-components-in-react"
|
||||
},
|
||||
"dependencies": {
|
||||
"@webcomponents/webcomponentsjs": "^2.5.0",
|
||||
|
|
|
@ -5,7 +5,11 @@ function MyApp({ Component, pageProps }) {
|
|||
return (
|
||||
<>
|
||||
<Head>
|
||||
<script src="/chill-counter.js" />
|
||||
<script src={`${process.env.NEXT_PUBLIC_BASE_PATH}/chill-counter.js`} />
|
||||
<link
|
||||
rel="icon"
|
||||
href={`${process.env.NEXT_PUBLIC_BASE_PATH}/favicon.ico`}
|
||||
/>
|
||||
</Head>
|
||||
<main>
|
||||
<AppNav />
|
||||
|
|
|
@ -1,6 +0,0 @@
|
|||
// Next.js API route support: https://nextjs.org/docs/api-routes/introduction
|
||||
|
||||
export default (req, res) => {
|
||||
res.statusCode = 200
|
||||
res.json({ name: 'John Doe' })
|
||||
}
|
Loading…
Reference in a new issue