So I have a reactjs project with typescript including scss, javascript is working perfeclty fine but page is loading without CSS.
my package.json file:
{
"name": "qb-front",
"version": "0.1.0",
"private": true,
"dependencies": {
"@babel/core": "^7.20.12",
"@mui/icons-material": "^5.11.0",
"@mui/material": "^5.11.3",
"@reduxjs/toolkit": "^1.8.3",
"@testing-library/jest-dom": "^5.16.4",
"@testing-library/react": "^13.3.0",
"@testing-library/user-event": "^14.2.3",
"@types/jest": "^27.5.2",
"@types/node": "^17.0.45",
"@types/react": "^18.0.15",
"@types/react-dom": "^18.0.6",
"@types/react-redux": "^7.1.24",
"@types/redux-saga": "^0.10.5",
"axios": "^0.27.2",
"bootstrap": "^5.2.0",
"formik": "^2.2.9",
"jquery": "^3.6.0",
"jwt-decode": "^3.1.2",
"moment": "^2.29.4",
"node-forge": ">=1.3.0",
"popper.js": "^1.16.1",
"react": "^18.2.0",
"react-bootstrap": "^2.5.0",
"react-dom": "^18.2.0",
"react-hot-toast": "^2.3.0",
"react-icons": "^4.4.0",
"react-player": "^2.11.0",
"react-redux": "^8.0.2",
"react-router-dom": "^6.3.0",
"react-scripts": "5.0.1",
"react-select": "^5.4.0",
"reactstrap": "^9.1.1",
"redux": "^4.2.0",
"redux-saga": "^1.1.3",
"sass": "^1.57.1",
"typescript": "^4.7.4",
"web-vitals": "^2.1.4",
"yup": "^0.32.11"
},
"scripts": {
"start": "react-scripts start tsc --watch",
"build": "GENERATE_SOURCEMAP=false PUBLIC_URL=/ react-scripts build",
"winBuild": "set \"GENERATE_SOURCEMAP=false\" && react-scripts build",
"test": "react-scripts test",
"eject": "react-scripts eject",
"lint": "eslint src/**/*.{js,jsx,ts,tsx,json}",
"lint:fix": "eslint --fix 'src/**/*.{js,jsx,ts,tsx,json}'",
"format": "prettier --write 'src/**/*.{js,jsx,ts,tsx,css,md,json}' --config ./.prettierrc",
"dev": "tsc --watch"
},
"eslintConfig": {
"extends": [
"react-app",
"react-app/jest"
]
},
"browserslist": {
"production": [
">0.2%",
"not dead",
"not op_mini all"
],
"development": [
"last 1 chrome version",
"last 1 firefox version",
"last 1 safari version"
]
},
"devDependencies": {
"@types/jquery": "^3.5.14",
"@types/prettier": "^2.7.2",
"@typescript-eslint/eslint-plugin": "^5.30.5",
"@typescript-eslint/parser": "^5.30.5",
"eslint": "^8.19.0",
"eslint-config-airbnb": "^19.0.4",
"eslint-config-prettier": "8.5.0",
"eslint-plugin-import": "^2.26.0",
"eslint-plugin-jsx-a11y": "^6.6.0",
"eslint-plugin-prettier": "4.2.1",
"eslint-plugin-react": "^7.30.1",
"eslint-plugin-react-hooks": "^4.6.0",
"prettier": "^2.8.2"
}
}
Localhost with npm start works perfectly fine, but when i build, css are gone.
Here is a screnshot from network:
Extra infos:
- project is running nginx and docker on a server node-16
- sass installed as normal dependency
- project has mui - bootstrap - scss
file structure: App.js has app.scss imported. app.scss has imported variables.scss from assets folder.
There are no errors in terminal, server and docker logs, and this is the only output for sass.
LOG from ./node_modules/react-scripts/node_modules/sass-loader/dist/cjs.js sass-loader ./node_modules/css-loader/dist/cjs.js??ruleSet[1].rules[1].oneOf[7].use[1]!./node_modules/postcss-loader/dist/cjs.js??ruleSet[1].rules[1].oneOf[7].use[2]!./node_modules/resolve-url-loader/index.js??ruleSet[1].rules[1].oneOf[7].use[3]!./node_modules/react-scripts/node_modules/sass-loader/dist/cjs.js??ruleSet[1].rules[1].oneOf[7].use[4]!./src/App.scss
<w> Deprecation $weight: Passing a number without unit % (100) is deprecated.
<w>
<w> To preserve current behavior: $weight * 1%
<w>
<w> More info: https://sass-lang.com/d/function-units
<w>
<w> node_modules\bootstrap\scss\_functions.scss 201:11 opaque()
<w> node_modules\bootstrap\scss\mixins\_table-variants.scss 4:28 table-variant()
<w> node_modules\bootstrap\scss\_tables.scss 147:3 @import
<w> node_modules\bootstrap\scss\bootstrap.scss 20:9 @import
<w> src\App.scss 1:9 root stylesheet
<w>
Update: new error that I occurred in mozzila firefox, I was using chrome/brave:
Layout was forced before the page was fully loaded. If stylesheets are not yet loaded this may cause a flash of unstyled content. node.js:396
The stylesheet /static/css/main.c4cbb89d.css was not loaded because its MIME type, “text/plain”, is not “text/css”.
im trying to use scss but it seems react is failing to compile.