-1

我正在构建一个 Nuxt 应用程序。我做了一些研究,但没有找到明确的解决方案。

Step 6/8 : EXPOSE 8080
 ---> Running in e5d36d6e86fe
Removing intermediate container e5d36d6e86fe
 ---> f655ef5cccc2
Step 7/8 : RUN npm run build
 ---> Running in f6445150af4c

> nuxt build

ℹ Production build
ℹ Bundling for server and client side
ℹ Target: server
ℹ Using components loader to optimize imports
ℹ Discovered Components: .nuxt/components/readme.md
✔ Builder initialized
✔ Nuxt files generated
ℹ Warming up worker pools
✔ Worker pools ready
ℹ Compiling Client
✔ Client: Compiled successfully in 1.00h
ℹ Compiling Server
✔ Server: Compiled successfully in 1.81m
4

1 回答 1

0

更新配置

有几种提高构建速度的实验方法。

https://nuxtjs.org/api/configuration-build#parallel

https://nuxtjs.org/api/configuration-build#cache

https://nuxtjs.org/api/configuration-build#hardsource

build: {
    // standalone: true,
    analyze: false,
    parallel: true,
    cache: true,
    hardSource: false,
    splitChunks: {
      layouts: false,
      pages: false,
      components: false,
    },
    html: {
      minify: {
        minifyCSS: false,
        minifyJS: false
      }
    },
    loaders: {
      vue: {
        prettify: false
      }
    },
    transpile: ["@coreui/vue", "@coreui/utils", "@ag-grid-community/vue"],
    extend(config, ctx) {
      if (ctx.isDev) {
        config.devtool = ctx.isClient ? "source-map" : "inline-source-map";
      }
    }
  }

Dockerfile

FROM node:14


COPY package*.json ./tmp/
RUN cd /tmp && npm install
RUN mkdir -p /usr/src/app && cp -a /tmp/node_modules /usr/src/app

WORKDIR /usr/src/app

COPY . .

#COPY package*.json ./
#RUN npm install

EXPOSE 8080

RUN npm run build
# RUN npm run generate

CMD [ "npm", "run", "start" ]

于 2021-03-18T08:48:24.547 回答