uiwjs / next-remove-imports

The default behavior is to remove all .less/.css/.scss/.sass/.styl imports from all packages in node_modules.
https://uiwjs.github.io/next-remove-imports/
MIT License
17 stars 2 forks source link

Usage with mjs configs #8

Open RobotSail opened 1 year ago

RobotSail commented 1 year ago

Hi all, I'm running into difficulty with using next-remove-imports in a project which uses next.config.mjs instead of the standard next.config.js, which is currently documented. Any guidance on how to proceed here?

My config currently looks like this:

// @ts-check

import removeImports from 'next-remove-imports'

/**
 * Run `build` or `dev` with `SKIP_ENV_VALIDATION` to skip env validation.
 * This is especially useful for Docker builds.
 */
!process.env.SKIP_ENV_VALIDATION && (await import("./src/env.mjs"));

/** @type {import("next").NextConfig} */
const config = {
  reactStrictMode: true,

  /**
   * If you have the "experimental: { appDir: true }" setting enabled, then you
   * must comment the below `i18n` config out.
   *
   * @see https://github.com/vercel/next.js/issues/41980
   */
  i18n: {
    locales: ["en"],
    defaultLocale: "en",
  },
  ...removeImports(),
};
export default config;
RobotSail commented 1 year ago

I've described the problem in this issue, but the problem seems to be that the TypeScript signature of removeImports doesn't allow me to provide my existing config, and merging the result of removeImports() doesn't seem to have any effect.

jaywcjlove commented 1 year ago

@RobotSail

https://github.com/uiwjs/next-remove-imports/blob/0e23be8ea25012e3131217a285586583dbf5ff36/core/src/index.ts#L8

import removeImports from 'next-remove-imports'

const removeImportsFun = removeImports({
  options: { },
})

export default removeImportsFun({
  reactStrictMode: true,
  i18n: {
    locales: ["en"],
    defaultLocale: "en",
  },
})
jaywcjlove commented 1 year ago

https://github.com/uiwjs/next-remove-imports/blob/e90b3441c8d2d519271eb1be1cab5f999f92848b/example/esm/next.config.mjs#L1-L16

RobotSail commented 1 year ago

Thanks @jaywcjlove!

ticmaisdev commented 1 year ago

I'm using this package exatcly as described in readme, but unable to import scss at component level still

jaywcjlove commented 1 year ago

@ticmaidev https://github.com/uiwjs/next-remove-imports/tree/main/example

You can provide a reproducible example through codesandbox.io, and I'll help you take a look.