Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Usage with mjs configs #8

Open
RobotSail opened this issue Feb 20, 2023 · 6 comments
Open

Usage with mjs configs #8

RobotSail opened this issue Feb 20, 2023 · 6 comments

Comments

@RobotSail
Copy link

RobotSail commented Feb 20, 2023

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
Copy link
Author

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
Copy link
Member

@RobotSail

export default (pluginOptions: PluginOptions = {}) => (nextConfig: NextConfig = {}): NextConfig => {

import removeImports from 'next-remove-imports'

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

export default removeImportsFun({
  reactStrictMode: true,
  i18n: {
    locales: ["en"],
    defaultLocale: "en",
  },
})

jaywcjlove added a commit that referenced this issue Feb 21, 2023
@jaywcjlove
Copy link
Member

import removeImports from 'next-remove-imports'
/** @type {function(import("next").NextConfig): import("next").NextConfig}} */
const removeImportsFun = removeImports({
options: { },
})
export default removeImportsFun({
webpack: function(config) {
config.module.rules.push({
test: /\.md$/,
use: 'raw-loader',
})
return config
},
})

@RobotSail
Copy link
Author

Thanks @jaywcjlove!

@ticmaisdev
Copy link

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

@jaywcjlove
Copy link
Member

@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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants