naviapps / create-nw-react-app

Create NW.js React apps with no build configuration.
MIT License
144 stars 14 forks source link

Can't use background-image: url(); in css and scss files #65

Open Username4212 opened 1 year ago

Username4212 commented 1 year ago

When using background-image: url(); in css or scss an error appears in the console.

Error:

Uncaught ReferenceError: __dirname is not defined
    at readFile chunk loading:1:1
    at readFile chunk loading:534:1
    at startup:7:1

I use npx create-nw-react-app@latest test to create the project. Here is the package.json file:

{
  "name": "test",
  "version": "0.1.0",
  "private": true,
  "dependencies": {
    "@testing-library/jest-dom": "^5.16.5",
    "@testing-library/react": "^13.4.0",
    "@testing-library/user-event": "^13.5.0",
    "nw-react-scripts": "5.1.0",
    "react": "^18.2.0",
    "react-dom": "^18.2.0",
    "web-vitals": "^2.1.4"
  },
  "scripts": {
    "start": "nw-react-scripts start",
    "build": "nw-react-scripts build",
    "test": "nw-react-scripts test",
    "eject": "nw-react-scripts eject"
  },
  "eslintConfig": {
    "extends": [
      "nw-react-app",
      "nw-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"
    ]
  },
  "main": "index.html",
  "nwbuilds": {
    "//": "https://nwutils.io/nw-builder/",
    "platforms": [
      "osx64",
      "win32",
      "win64"
    ],
    "version": "latest",
    "flavor": "normal",
    "outDir": "./out",
    "cacheDir": "./cache",
    "app": {
      "name": "test",
      "icon": "./src/logo.icns"
    }
  }
}

OS: Window 10 x64 Node.js: v14.19.0 (but it also don't work on 18.16.0)

naviapis commented 1 year ago

I just updated.

Change package.json

  {
    "dependencies": {
      ...
-     "nw-react-scripts": "5.1.0",
+     "nw-react-scripts": "5.1.1",
      ...
    },
  }

Package install

npm install

I think it will work with this change.