Browse Source

fix: alias not work after config semi-next in next.js project, close #630 (#658)

pointhalo 3 years ago
parent
commit
1d87b98bee
1 changed files with 4 additions and 1 deletions
  1. 4 1
      packages/semi-next/src/index.ts

+ 4 - 1
packages/semi-next/src/index.ts

@@ -9,7 +9,7 @@ export default function(options: SemiNextOptions = {}) {
     return (nextConfig: NextConfig = {}) => {
         const actualConfig: NextConfig = {
             ...nextConfig,
-            webpack(config, { isServer, webpack }) {
+            webpack(config, { isServer, webpack, ...rest }) {
                 config.plugins.push(new SemiWebpackPlugin({
                     omitCss: options.omitCss === undefined ? true : options.omitCss,
                     webpackContext: {
@@ -39,6 +39,9 @@ export default function(options: SemiNextOptions = {}) {
                         ];
                     }
                 }
+                if (typeof nextConfig.webpack === 'function') {
+                    return nextConfig.webpack(config, { isServer, webpack, ...rest });
+                }
                 return config;
             }
         };