Next.js Discord

Discord Forum

How do I define the order of Webpack plugins in App directory?

Unanswered
Orinoco Crocodile posted this in #help-forum
Open in Discord
Orinoco CrocodileOP
I have a code-transform that I have written, but it's meant to run before any other code transformations made by Next.js. How can I accomplish this?

This is my code:

import { webpack } from "@scope/my-plugin"

/** @type {import('next').NextConfig} */
const nextConfig = {
    webpack(config) {
        config.plugins = config.plugins ?? []
        config.infrastructureLogging = { level: 'error' }

        config.plugins.unshift(webpack({
            next: {
                serverActionsPaths: [
                    "./lib/actions.js"
                ]
            }
        }))
        return config
    }
};

export default nextConfig;


Even with the unshift it doesn't work? By the time my pluigin processes code, its already in a really mangled state.

0 Replies