powered by simpleCommunicator - 2.0.48     © 2025 Programmizd 02
Форумы / HTML, JavaScript, VBScript, CSS [игнор отключен] [закрыт для гостей] / Задокеризировать NuxtJS приложение с css-препроцессором
2 сообщений из 2, страница 1 из 1
Задокеризировать NuxtJS приложение с css-препроцессором
    #40021764
vb_sub
Скрыть профиль Поместить в игнор-лист Сообщения автора в теме
Участник
Всем привет пытаюсь создать Docker-образ Nuxt-приложения, в котором используется SCSS-препроцессор стилей.
Код: powershell
1.
2.
3.
4.
5.
6.
7.
8.
9.
10.
11.
12.
13.
14.
15.
16.
17.
18.
19.
20.
# Stage 1 - build
FROM node:15.2.1-alpine3.10 AS builder
WORKDIR /app
COPY package*.json ./
RUN  npm install --production
COPY . .
RUN npm run build --production

# Stage 2 - production
FROM node:15.2.1-alpine AS final
WORKDIR /app
ADD package.json .
ADD nuxt.config.js .
COPY --from=builder /app/.nuxt ./.nuxt
COPY --from=builder /app/node_modules ./node_modules
COPY --from=builder /app/static ./static
ENV NUXT_HOST=0.0.0.0
ENV NUXT_PORT=3000
EXPOSE 3000
CMD ["npm", "start"]


.dockerIgnore
Код: powershell
1.
2.
3.
node_modules/
dist/
.nuxt/


nuxt.config.js
Код: javascript
1.
2.
3.
4.
5.
6.
7.
8.
9.
10.
11.
12.
13.
14.
15.
16.
17.
18.
19.
20.
21.
22.
23.
24.
25.
26.
27.
28.
29.
30.
31.
32.
33.
34.
35.
36.
37.
38.
39.
40.
41.
42.
43.
44.
45.
46.
47.
48.
49.
50.
51.
52.
53.
export default {
  mode: 'universal',
  target: 'server',
  head: {
    title: process.env.npm_package_name || '',
    meta: [
      { charset: 'utf-8' },
      { name: 'viewport', content: 'width=device-width, initial-scale=1' },
      { hid: 'description', name: 'description', content: process.env.npm_package_description || '' }
    ],
    link: [
      { rel: 'icon', type: 'image/x-icon', href: '/favicon.ico' }
    ]
  },
  css: [
  ],
  plugins:  ["~/plugins/axios-port.js"],
  components: true,
  buildModules: [
    // '@nuxtjs/style-resources'- не помогает внесение модуля в эту секцию
  ],
  /*
  ** Nuxt.js modules
  */
  modules: [
    '@nuxtjs/axios',
    ['@nuxtjs/style-resources']
  ],
  styleResources: {
    scss: [
      '~assets/scss/main.scss',
    ]
},
  axios: {
    baseURL: 'http://localhost:5000/api',
    headers:{
      get: {
        'Cache-Control': 'no-cache'
      }
    }
  },
  env:{
   assigementHub:'http://localhost:5000/assigements'
  },
  build: {
    analyze: false,
    extend(config, ctx) {
      if (ctx.isDev) {
        config.devtool = ctx.isClient ? 'source-map' : 'inline-source-map'
      }
    }
  }
}


package.json
Код: javascript
1.
2.
3.
4.
5.
6.
7.
8.
9.
10.
11.
12.
13.
14.
15.
16.
17.
18.
19.
20.
21.
22.
23.
24.
25.
26.
27.
28.
29.
30.
31.
32.
33.
34.
35.
{
  "name": "BrigPlanning",
  "version": "1.0.0",
  "private": true,
  "scripts": {
    "dev": "nuxt",
    "build": "nuxt build --modern=server",
    "start": "nuxt start --modern=server",
    "generate": "nuxt generate",
    "lint:js": "eslint --ext .js,.vue --ignore-path .gitignore .",
    "lint": "npm run lint:js"
  },
  "dependencies": {
    "@nuxtjs/axios": "^5.12.0",
    "nuxt": "^2.14.0"
  },
  "devDependencies": {
    "@nuxtjs/eslint-config": "^3.1.0",
    "@nuxtjs/eslint-module": "^2.0.0",
    "@nuxtjs/style-resources": "^1.0.0",
    "babel-eslint": "^10.1.0",
    "eslint": "^7.5.0",
    "eslint-plugin-nuxt": "^1.0.0",
    "node-sass": "^4.14.1",
    "pug": "^3.0.0",
    "pug-plain-loader": "^1.0.0",
    "sass-loader": "^9.0.3"
  },
  "config": {
    "nuxt": {
      "host": "0.0.0.0",
      "port": "3000"
    }
   }
}


При формировании docker-образа получаю ошибку на этапе "RUN npm run build"
#15 1.353 Error: Cannot find module '@nuxtjs/style-resources'
#15 1.353 Require stack:
#15 1.353 - node_modules/@nuxt/core/dist/core.js
#15 1.353 - node_modules/@nuxt/cli/dist/cli-index.js
#15 1.353 - node_modules/@nuxt/cli/dist/cli.js
#15 1.353 - node_modules/nuxt/bin/nuxt.js
#15 1.353 at Resolver.requireModule (node_modules/@nuxt/core/dist/core.js:615:31)
#15 1.353 at ModuleContainer.addModule (node_modules/@nuxt/core/dist/core.js:180:38)
#15 1.353 at node_modules/@nuxt/utils/dist/utils.js:1846:43
#15 1.353 at async ModuleContainer.ready (node_modules/@nuxt/core/dist/core.js:55:5)
#15 1.353 at async Nuxt._init (node_modules/@nuxt/core/dist/core.js:715:5)
То есть почему-то модуль загрузки ресурсов не может найтись, хотя если я делаю теже самые операции докер-файла вне докера, то все билдится нормально.
Что пробовал:
переносить '@nuxtjs/style-resources' в секцию buildModules файла nuxt.config.js
переносить зависимости препроцессора из devDependencies в dependencies
билдить без production-флага
заменять строку RUN npm install --production на RUN npm install --productio && rebuild node-sass
Ничего соответственно не помогло.
Подскажите что еще можно попробовать? Спасибо
...
Рейтинг: 0 / 0
Задокеризировать NuxtJS приложение с css-препроцессором
    #40023262
vb_sub
Скрыть профиль Поместить в игнор-лист Сообщения автора в теме
Участник
чтобы заработало нужно убрать флаг --production из RUN npm install --production
...
Рейтинг: 0 / 0
2 сообщений из 2, страница 1 из 1
Форумы / HTML, JavaScript, VBScript, CSS [игнор отключен] [закрыт для гостей] / Задокеризировать NuxtJS приложение с css-препроцессором
Целевая тема:
Создать новую тему:
Автор:
Закрыть
Цитировать
Найденые пользователи ...
Разблокировать пользователей ...
Читали форум (0):
Пользователи онлайн (0):
x
x
Закрыть


Просмотр
0 / 0
Close
Debug Console [Select Text]