Closed mzenz closed 1 year ago
duplicate #2177
This issue is fixed with https://github.com/nuxt/nuxt/pull/21864 You can try to confirm nuxt edge channel
Thanks!
This issue is still a thing when building using Docker.
I'm using the following package.json:
{
...,
"dependencies": {
"@babel/runtime-corejs3": "^7.22.5",
"@fortawesome/fontawesome-free": "^5.15.4",
"@fortawesome/free-brands-svg-icons": "^5.15.4",
"@fortawesome/free-regular-svg-icons": "^5.15.4",
"@fortawesome/free-solid-svg-icons": "^5.15.4",
"@fortawesome/vue-fontawesome": "^3.0.3",
"@googlemaps/markerclusterer": "^2.3.2",
"@pinia-orm/nuxt": "^1.7.0",
"@sentry/browser": "^7.73.0",
"@sentry/cli": "^2.19.1",
"@sentry/tracing": "^7.57.0",
"@sentry/vue": "^7.57.0",
"@vuelidate/core": "^2.0.3",
"@vuelidate/validators": "^2.0.3",
"admin-lte": "^3.2.0",
"animate.css": "^4.1.1",
"axios": "^0.27.2",
"babel-plugin-module-resolver": "^5.0.0",
"date-fns": "^2.30.0",
"firebase": "^10.0.0",
"geojson": "^0.5.0",
"http-status-codes": "^2.3.0",
"is-https": "^4.0.0",
"leaflet": "1.9.4",
"lodash": "^4.17.21",
"maska": "^2.1.10",
"mime-types": "^2.1.35",
"nuxt-leaflet": "0.0.27",
"ofetch": "^1.3.3",
"papaparse": "^5.4.1",
"pinia": "^2.1.6",
"pinia-orm": "^1.7.2",
"pluralize": "^8.0.0",
"portal-vue": "^3.0.0",
"requrl": "^3.0.2",
"uuid": "^9.0.0"
},
"devDependencies": {
"@babel/core": "^7.22.5",
"@babel/eslint-parser": "^7.22.5",
"@babel/preset-env": "^7.22.20",
"@bootstrap-vue-next/nuxt": "^0.13.3",
"@commitlint/cli": "^17.7.2",
"@commitlint/config-conventional": "^17.6.5",
"@dargmuesli/nuxt-cookie-control": "^6.4.3",
"@intlify/unplugin-vue-i18n": "^0.8.2",
"@nuxt/content": "^2.8.2",
"@nuxt/devtools": "^0.8.4",
"@nuxt/devtools-ui-kit": "^0.8.4",
"@nuxt/image": "^1.0.0-rc.1",
"@nuxt/test-utils": "^0.2.2",
"@nuxt/types": "^2.17.1",
"@nuxt/webpack-builder": "^3.7.4",
"@nuxtjs/color-mode": "^3.3.0",
"@nuxtjs/device": "^3.1.1",
"@nuxtjs/eslint-config": "^12.0.0",
"@nuxtjs/eslint-module": "^4.1.0",
"@nuxtjs/fontawesome": "^1.1.2",
"@nuxtjs/google-adsense": "^2.1.0",
"@nuxtjs/google-fonts": "^3.0.2",
"@nuxtjs/html-validator": "^1.5.2",
"@nuxtjs/i18n": "^8.0.0-rc.4",
"@nuxtjs/robots": "^3.0.0",
"@nuxtjs/stylelint-module": "^5.1.0",
"@pinia/nuxt": "^0.4.11",
"@sentry/webpack-plugin": "^2.7.1",
"@sidebase/nuxt-auth": "^0.6.0-beta.5",
"@sidebase/nuxt-session": "^0.2.7",
"@types/leaflet": "^1.9.6",
"@types/node": "^18.16.19",
"@typescript-eslint/eslint-plugin": "^5.62.0",
"@typescript-eslint/parser": "^5.62.0",
"@unhead/schema-org": "^1.7.4",
"@vueuse/core": "^10.4.1",
"@vueuse/nuxt": "^10.4.1",
"bootstrap": "^5.3.2",
"bootstrap-vue-next": "^0.13.2",
"cross-env": "^7.0.3",
"dayjs-nuxt": "^1.1.2",
"eslint": "^8.45.0",
"eslint-config-prettier": "^8.5.0",
"eslint-plugin-import": "^2.26.0",
"eslint-plugin-jest": "^27.0.4",
"eslint-plugin-lodash": "^7.4.0",
"eslint-plugin-node": "^11.1.0",
"eslint-plugin-nuxt": "^4.0.0",
"eslint-plugin-prettier": "^4.2.1",
"eslint-plugin-unicorn": "^47.0.0",
"eslint-plugin-vue": "^9.5.1",
"fibers": "^5.0.3",
"husky": "^8.0.3",
"jest": "^29.5.0",
"jest-environment-jsdom": "^29.5.0",
"jest-scss-transform": "^1.0.3",
"jest-serializer-vue": "^2.0.2",
"js-beautify": "^1.14.9",
"jsdom-global": "^3.0.2",
"json-loader": "^0.5.7",
"lint-staged": "^13.2.2",
"mapbox-gl": "^2.15.0",
"next-auth": "4.22.3",
"nuxt": "^3.7.4",
"nuxt-bugsnag": "^7.0.0",
"nuxt-gtag": "^1.1.1",
"nuxt-icon": "^0.5.0",
"nuxt-lodash": "^2.5.0",
"nuxt-mapbox": "^1.4.4",
"nuxt-module-feed": "^1.0.3",
"nuxt-security": "^0.14.4",
"nuxt-simple-sitemap": "^3.3.4",
"nuxt-swiper": "^1.2.2",
"postcss": ">=8.4.31",
"prettier": "^3.0.3",
"require-extension-hooks": "^0.3.3",
"require-extension-hooks-babel": "^1.0.0",
"require-extension-hooks-vue": "^3.0.0",
"sass": "^1.68.0",
"sass-loader": "^10.3.1",
"semver": "^7.5.4",
"stylelint": "^15.10.3",
"stylelint-config-recommended-vue": "^1.4.0",
"stylelint-config-standard": "^33.0.0",
"tsutils": "^3.21.0",
"typescript": "^5.1.3",
"vite-plugin-electron": "^0.14.1",
"vite-plugin-electron-renderer": "^0.14.5",
"vue-eslint-parser": "^9.3.1",
"vue-jest": "^3.0.4"
}
}
Here is my Dockerfile:
# syntax = docker/dockerfile:1
ARG NODE_VERSION=18.18.2
FROM node:${NODE_VERSION} as base
ARG PORT=3000
ENV NODE_ENV=production
WORKDIR /
# Build
FROM base as build
COPY --link package.json package-lock.json .
RUN npm install --production=false
COPY --link . .
RUN npm run build
RUN npm prune
# Run
FROM base as run
ENV PORT=$PORT
COPY --from=build /.output /.output
# Optional, only needed if you rely on unbundled dependencies
COPY --from=build /node_modules /node_modules
CMD [ "node", ".output/server/index.mjs" ]
This issue only occurs when building a Docker image. A regular npm run build && npm run preview
works, as does npm run build && node ./.output/server/index.mjs
.
I'm currently in the process of removing packages until the bug no longer exists.
I will also try a fresh app with only Bootstrap Vue and see if the SCSS still compiles.
Also, I'm not entirely sure if my issue is related to cached Docker builds, but I've tried building with different tags & versions, but the end results is always missing CSS.
@codetheorist
Have you tried building your project, then copying the .output and node_modules (as you do in your Dockerfile) into a seperate folder and running node ./.output/server/index.mjs
? This at least would exclude any issues caused from copying and missing some assets.
Still, I doubt this issue is caused by @nuxtjs/i18n
, but if it is I would be happy to look into it if you could provide a minimal reproduction 😅
So, I'm not sure what the issue was.
I ended up starting a fresh project and progressively copying parts from the old project to the new, to see when the CSS stopped working. It didn't stop working.
Weird issue and I've never got to the bottom of what was causing it.
Environment
Reproduction
https://github.com/mzenz/nuxt-i18n-ssg-bug
Describe the bug
When configuring i18n via
i18n.config.ts
prerendering vianuxt generate
, CSS styles are not present in the prerendered output.This is fixed by removing
i18n.config.ts
altogether which means some i18n options can't be configured.Steps to reproduce
git clone https://github.com/mzenz/nuxt-i18n-ssg-bug.git
yarn install
yarn generate
yarn serve
to start a local static web serverhttp://localhost:3000
Actual results
<style>
tag is missing insindedist/index.html
.Expected results
index.html
Additional context
Broken
index.html
(no<style>
tag):Sane
index.html
(i.e.<style>
tag present):Logs