Przeglądaj źródła

fix the condition to use next-transpile-modules

Yuki Takei 3 lat temu
rodzic
commit
7e91c27d2e
2 zmienionych plików z 4 dodań i 6 usunięć
  1. 3 5
      packages/app/next.config.js
  2. 1 1
      packages/app/package.json

+ 3 - 5
packages/app/next.config.js

@@ -12,7 +12,7 @@ const { i18n, localePath } = require('./src/next-i18next.config');
 
 
 const isProduction = process.env.NODE_ENV === 'production';
-let isServer = true;
+const isBuildingNext = process.env.BUILDING_NEXT === 'true';
 
 
 // define additional entries
@@ -37,11 +37,9 @@ const nextConfig = {
 
   /** @param config {import('next').NextConfig} */
   webpack(config, options) {
-    isServer = options.isServer;
-
     // Avoid "Module not found: Can't resolve 'fs'"
     // See: https://stackoverflow.com/a/68511591
-    if (!isServer) {
+    if (!options.isServer) {
       config.resolve.fallback.fs = false;
     }
 
@@ -79,7 +77,7 @@ const nextConfig = {
 const passThrough = nextConfig => nextConfig;
 let withTM = passThrough;
 
-if (!isProduction || !isServer) {
+if (!isProduction || isBuildingNext) {
   const { listScopedPackages, listPrefixedPackages } = require('./src/utils/next.config.utils');
 
   // setup logger

+ 1 - 1
packages/app/package.json

@@ -6,7 +6,7 @@
     "//// for production": "",
     "build": "run-p build:*",
     "start": "yarn next start",
-    "build:client": "yarn next build",
+    "build:client": "yarn cross-env BUILDING_NEXT=true yarn next build",
     "prebuild:client": "tsc -p tsconfig.build.next.config.json",
     "build:server": "yarn cross-env NODE_ENV=production tsc -p tsconfig.build.server.json && tsc-alias -p tsconfig.build.server.json",
     "postbuild:server": "npx -y shx mv transpiled/src dist && npx -y shx cp -r transpiled/config/* config && npx -y shx cp -r src/server/views dist/server/ && npx -y shx rm -rf transpiled",