Skip to content

Latest commit

 

History

History
45 lines (31 loc) · 1.34 KB

README.md

File metadata and controls

45 lines (31 loc) · 1.34 KB

next-transpile-vendor-styles

semantic-release GitHub license badge npm

Adds support for vendor style transpilation for next.js. Based on https://github.com/martpie/next-transpile-modules.

Install

yarn add @freshcells/next-transpile-vendor-styles

Usage

In your nextjs.config.mjs

import { PHASE_PRODUCTION_SERVER } from 'next/constants.js'

export default async (phase) => {
    if (phase === PHASE_PRODUCTION_SERVER) {
        return { /* your nextjs config */ }
    }

    // Lazy load modules we require for the compilation only.
    // This way we can later omit the package for production
    
    const transpileVendorStyles = await import('@freshcells/next-transpile-vendor-styles')

    return withTransform = transpileVendorStyles.default([
        '@your-namespace/module-1',
        '@your-namespace/module-2'
    ])
    
    return withTransform({
        /* your nextjs config */
    })
}