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

Can't use with next-compose-plugins and Nx #2

Closed binary64 closed 2 years ago

binary64 commented 2 years ago

Hi, I'm trying to use this plugin to remove antd imports from nextjs:

const withNx = require('@nrwl/next/plugins/with-nx')
const withPlugins = require('next-compose-plugins')
const withLess = require('next-with-less')
const withYaml = require('next-plugin-yaml')
const removeImports = require('next-remove-imports')

module.exports = withPlugins([
  [
    removeImports,
    {
      experimental: { esmExternals: true },
    },
  ],
  [withYaml],
  [
    withLess,
    {
      lessLoaderOptions: {
        javascriptEnabled: true,
        modifyVars: { '@primary-color': '#ff0000' },
        localsConvention: 'camelCase',
      },
    },
  ],
  [
    withNx,
    {
      nx: {
        svgr: true,
      },
      cssModules: true,
      webpack5: false,
    },
  ],
])

However I don't see any change in nextjs output:

[WEB] wait  - compiling...
[WEB] error - C:/p/monorepo/node_modules/antd/lib/alert/style/index.less
[WEB] Global CSS cannot be imported from within node_modules.
[WEB] Read more: https://nextjs.org/docs/messages/css-npm
[WEB] Location: ..\..\node_modules\antd\lib\alert\style\index.js

Am I doing something wrong?

I tried putting the removeImports section at the top, middle, and bottom - no effect.

jaywcjlove commented 2 years ago

@binary64 I have not studied this configuration. Can you provide examples?

binary64 commented 2 years ago

Thanks for your prompt reply. Hmm I'm stuck. My example repo at https://github.com/binary64/nx-antd that I have built for you works perfectly! I shall have to bisect my main project. Will report back here when I have a finding.

binary64 commented 2 years ago

It seems to work now. Not sure what happened before! Sorry for the false ticket.