excalith / excalith-start-page

Terminal-inspired, clean, feature-rich and customizable browser start page for geeks. Has built-in editor for customizing.
https://excalith-start-page.vercel.app
MIT License
554 stars 163 forks source link

[BUG] yarn export not working #79

Closed ncvescera closed 4 months ago

ncvescera commented 4 months ago

Describe The Bug

When I run the yarn export command I get the following error:

yarn run v1.22.22
$ next export
 ⨯
    The "next export" command has been removed in favor of "output: export" in next.config.js. Learn more: https://nextjs.org/docs/advanced-features/static-html-export

error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.

By changing the output field from standalone to export (in next.config.js) and running the yarn build command I manage to obtain the build, but when I try to open the out/index.html file I get a blank page.

//next.config.js
const rulesToProcess = [/\.m?js/, /\.(js|cjs|mjs)$/].map(String)
const dirToIgnore = /tools/

const nextConfig = {
    reactStrictMode: true,
-       output: "standalone",
+       output: "export",
    publicRuntimeConfig: {
        version
    },
    images: {
        unoptimized: true,
        remotePatterns: [
            {
                protocol: "https",
                hostname: "**"
            }
        ]
    },
    headers: () => [
        {
            source: "/:path*",
            headers: [
                {
                    key: "Cache-Control",
                    value: "no-store"
                }
            ]
        }
    ],
    webpack(config) {
        config.resolve.fallback = {
            // if you miss it, all the other options in fallback, specified
            // by next.js will be dropped.
            ...config.resolve.fallback,

            fs: false // the solution
        }

        config.module.rules = config.module.rules.map((rule) => {
            if (rule !== "..." && rulesToProcess.indexOf(String(rule.test)) > -1) {
                rule.exclude = [dirToIgnore]
            }
            return rule
        })

        return config
    },
    env: {
        BUILD_MODE: process.env.BUILD_MODE
    }
}

module.exports = nextConfig

Inspecting the page I see the following errors and wornings:

Cross-Origin Request Blocked: The Same Origin Policy disallows reading the remote resource at file:///_next/static/css/dec7afba07758c41.css. (Reason: CORS request not http).

Cross-Origin Request Blocked: The Same Origin Policy disallows reading the remote resource at file:///_next/static/css/607fb85db1ac148f.css. (Reason: CORS request not http).

Cross-Origin Request Blocked: The Same Origin Policy disallows reading the remote resource at file:///_next/static/chunks/webpack-4461f78ae6345ca1.js. (Reason: CORS request not http).

Cross-Origin Request Blocked: The Same Origin Policy disallows reading the remote resource at file:///_next/static/chunks/framework-5429a50ba5373c56.js. (Reason: CORS request not http).

Cross-Origin Request Blocked: The Same Origin Policy disallows reading the remote resource at file:///_next/static/chunks/main-359cf9259ad67a06.js. (Reason: CORS request not http).

Cross-Origin Request Blocked: The Same Origin Policy disallows reading the remote resource at file:///_next/static/chunks/pages/_app-f1f6d5684b7c625b.js. (Reason: CORS request not http).

Cross-Origin Request Blocked: The Same Origin Policy disallows reading the remote resource at file:///_next/static/chunks/75fc9c18-af385d3bdb0a9ad1.js. (Reason: CORS request not http).

Cross-Origin Request Blocked: The Same Origin Policy disallows reading the remote resource at file:///_next/static/chunks/152-39dfe41610587be7.js. (Reason: CORS request not http).

Cross-Origin Request Blocked: The Same Origin Policy disallows reading the remote resource at file:///_next/static/chunks/pages/index-ecdbfcd1250bab28.js. (Reason: CORS request not http).

Cross-Origin Request Blocked: The Same Origin Policy disallows reading the remote resource at file:///_next/static/9BAVkGOzLyo-hn8nA_nLS/_buildManifest.js. (Reason: CORS request not http).

Cross-Origin Request Blocked: The Same Origin Policy disallows reading the remote resource at file:///_next/static/9BAVkGOzLyo-hn8nA_nLS/_ssgManifest.js. (Reason: CORS request not http).

Cross-Origin Request Blocked: The Same Origin Policy disallows reading the remote resource at file:///_next/static/css/dec7afba07758c41.css. (Reason: CORS request not http).

Cross-Origin Request Blocked: The Same Origin Policy disallows reading the remote resource at file:///_next/static/css/607fb85db1ac148f.css. (Reason: CORS request not http).

Cross-Origin Request Blocked: The Same Origin Policy disallows reading the remote resource at file:///_next/static/chunks/webpack-4461f78ae6345ca1.js. (Reason: CORS request not http).

<script> source URI is not allowed in this document: “file:///_next/static/chunks/webpack-4461f78ae6345ca1.js”. index.html:1:842
Cross-Origin Request Blocked: The Same Origin Policy disallows reading the remote resource at file:///_next/static/chunks/framework-5429a50ba5373c56.js. (Reason: CORS request not http).

<script> source URI is not allowed in this document: “file:///_next/static/chunks/framework-5429a50ba5373c56.js”. index.html:1:940
Cross-Origin Request Blocked: The Same Origin Policy disallows reading the remote resource at file:///_next/static/chunks/main-359cf9259ad67a06.js. (Reason: CORS request not http).

<script> source URI is not allowed in this document: “file:///_next/static/chunks/main-359cf9259ad67a06.js”. index.html:1:1033
Cross-Origin Request Blocked: The Same Origin Policy disallows reading the remote resource at file:///_next/static/chunks/pages/_app-f1f6d5684b7c625b.js. (Reason: CORS request not http).

<script> source URI is not allowed in this document: “file:///_next/static/chunks/pages/_app-f1f6d5684b7c625b.js”. index.html:1:1132
Cross-Origin Request Blocked: The Same Origin Policy disallows reading the remote resource at file:///_next/static/chunks/75fc9c18-af385d3bdb0a9ad1.js. (Reason: CORS request not http).

<script> source URI is not allowed in this document: “file:///_next/static/chunks/75fc9c18-af385d3bdb0a9ad1.js”. index.html:1:1229
Cross-Origin Request Blocked: The Same Origin Policy disallows reading the remote resource at file:///_next/static/chunks/152-39dfe41610587be7.js. (Reason: CORS request not http).

<script> source URI is not allowed in this document: “file:///_next/static/chunks/152-39dfe41610587be7.js”. index.html:1:1321
Cross-Origin Request Blocked: The Same Origin Policy disallows reading the remote resource at file:///_next/static/chunks/pages/index-ecdbfcd1250bab28.js. (Reason: CORS request not http).

<script> source URI is not allowed in this document: “file:///_next/static/chunks/pages/index-ecdbfcd1250bab28.js”. index.html:1:1421
Cross-Origin Request Blocked: The Same Origin Policy disallows reading the remote resource at file:///_next/static/9BAVkGOzLyo-hn8nA_nLS/_buildManifest.js. (Reason: CORS request not http).

<script> source URI is not allowed in this document: “file:///_next/static/9BAVkGOzLyo-hn8nA_nLS/_buildManifest.js”. index.html:1:1522
Cross-Origin Request Blocked: The Same Origin Policy disallows reading the remote resource at file:///_next/static/9BAVkGOzLyo-hn8nA_nLS/_ssgManifest.js. (Reason: CORS request not http).

<script> source URI is not allowed in this document: “file:///_next/static/9BAVkGOzLyo-hn8nA_nLS/_ssgManifest.js”.

To Reproduce

Steps to reproduce the behavior:

  1. Run yarn export
  2. Change the output field from standalone to export inside next.config.js
  3. Run yarn build
  4. Open out/index.html file

Specs

excalith commented 4 months ago

Hey @ncvescera, unfortunately statically exporting is not available. It uses api calls so you can only build and host locally instead of using static. This was a requirement due to supporting images, and might find a workaround for exporting one day but not the priority right now. Sorry about that.

Not closing the issue if you have further questions, but feel free to close it whenever you want.

Cheers!

ncvescera commented 4 months ago

@excalith thank you for the help !

This was a requirement due to supporting images,

Is this an optional feature ? Could it be disabled ?

excalith commented 4 months ago

Unfortunately it is how next builds it. Maybe there can be a workaround, but as far as I know it currently does not support that.

ncvescera commented 4 months ago

Unfortunately it is how next builds it. Maybe there can be a workaround, but as far as I know it currently does not support that.

Thanks so much for your help ❤️! Now that my questions are answered, I'm good to go and will close out this issue.