actions / configure-pages

An action to enable Pages and extract various metadata about a site. It can also be used to configure various static site generators we support as starter workflows.
https://pages.github.com
MIT License
130 stars 54 forks source link

Configuration seems to struggle with Next.js PWA configurations #44

Open haykam821 opened 1 year ago

haykam821 commented 1 year ago

I am working on migrating a web application to Next.js in this repo. However, I am running into an issue where the basePath is seemingly not injected.

My configuration looks like the following:

const withPWA = require("next-pwa")({
    dest: "public",
});

module.exports = withPWA({
    compiler: {
        styledComponents: true,
    },
    reactStrictMode: true,
});

However, the step using the actions/configure-pages action outputs this warning from #43:

Warning: Unsupported configuration file extension. Currently supported extensions: ".js", ".cjs", ".mjs"

Other than the fact that the next.config.js configuration uses the .js extension, it seems that the action fails to inject properties into a configuration wrapped by a higher-order withPWA function. A more useful error is not logged, so this issue is hard to diagnose.

zvailanu98 commented 1 year ago

I'm having the same issue with withContentlayer(). A lot of Next.js "plugins" wrap the config in this way, which doesn't seem to work with this action.

DenizUgur commented 1 year ago

Weird that no workaround or fix has been proposed here

haykam821 commented 1 year ago

This action seems to support wrapping calls already, but the functionality for doing so seems to not be enabled. The ConfigParser constructor simply needs to be passed allowWrappingCall: true in its settings:

https://github.com/actions/configure-pages/blob/f156874f8191504dae5b037505266ed5dda6c382/src/set-pages-config.js#L77-L79

The parsing for wrapping calls only seems to allow one wrapping call, though, so multiple higher-order functions would not be usable even if allowWrappingCall: true was specified.

atkinchris commented 1 month ago

I've raised a PR to introduce @haykam821's fix here: https://github.com/actions/configure-pages/pull/161.