Next 11 css-loader 在 Docker 内部的构建过程中针对 fomantic-ui 本地构建的文件抛出错误

问题描述 投票:0回答:0

我正在项目中使用

"next": "^11.1.4"
"fomantic-ui": "^2.9.2"
,我不知道如何处理下面描述的情况。

构建过程需要两个步骤:

  1. fomantic-ui 用 gulp 构建,
  2. 使用 next 构建下一个应用程序

本地构建过程正常,但在 Docker 内部它总是抛出相同的错误。

#18 69.74 ./src/semantic/dist/semantic.min.css.webpack[javascript/auto]!=!./node_modules/next/dist/compiled/css-loader/cjs.js??ruleSet[1].rules[2].oneOf[6].use[1]!./node_modules/next/dist/compiled/postcss-loader/cjs.js??ruleSet[1].rules[2].oneOf[6].use[2]!./src/semantic/dist/semantic.min.css
#18 69.74 Error: Unknown node type in node creation
#18 69.74     at Array.map (<anonymous>)
#18 69.74
#18 69.74
#18 69.74 > Build error occurred
#18 69.74 Error: > Build failed because of webpack errors
#18 69.74     at /app/node_modules/next/dist/build/index.js:397:19
#18 69.74     at async Span.traceAsyncFn (/app/node_modules/next/dist/telemetry/trace/trace.js:60:20)
#18 69.74     at async Object.build [as default] (/app/node_modules/next/dist/build/index.js:77:25)

Dockerfile 内容:

# Install dependencies only when needed
FROM node:14-alpine3.17 AS base

FROM base as deps
# Check https://github.com/nodejs/docker-node/tree/b4117f9333da4138b03a546ec926ef50a31506c3#nodealpine to understand why libc6-compat might be needed.
RUN apk update && apk upgrade && apk add --no-cache libc6-compat python3 make g++ tree bash git openssh

WORKDIR /app

COPY package.json yarn.lock ./
COPY semantic.json ./
COPY tools/preinstall-script.js ./tools/
COPY src/semantic ./src/semantic

# run yarn install, ignore scripts, filter out warnings
# https://github.com/yarnpkg/yarn/issues/6672#issuecomment-551136196
RUN yarn install --frozen-lockfile 2> >(grep -v warning 1>&2)

RUN yarn semantic

# Rebuild the source code only when needed
FROM base as builder
WORKDIR /app

COPY . .

# take only what we need, removing all unused stuff from previous steps
COPY --from=deps /app/node_modules ./node_modules
COPY --from=deps /app/src/semantic/dist ./src/semantic/dist

ENV NEXT_TELEMETRY_DISABLED 1
RUN yarn build

# Production image, copy all the files and run next
FROM base AS runner
WORKDIR /app

ENV NODE_ENV production

COPY --from=builder /app .

EXPOSE 80

CMD ["yarn", "start:prod", "-p", "80"]

附言将“fomantic-ui”从

"^2.9.2"
更新为
"^2.8.3"
后出现此错误,因此有一个考虑,即
nextjs@^11
加载器不支持CSS
@supports
功能,我必须更新到next@^13,我目前想避免什么。

P.P.S.我在主机上获得成功构建的事实证明了 P.S.上面,因为如果这些考虑是真的,那么即使在本地我也会失败构建。

docker webpack next.js semantic-ui
© www.soinside.com 2019 - 2024. All rights reserved.