0

I have a react js project, and have made some changes to the webpack.config.js file located inside my node_modules directory. I have my project deployed on netlify but because node_modules is included in my .gitignore file, I don't have a way to reflect the changes that I made to my webpack configuration.

Edit: My package.json

{
  "name": "taisei-portfolio",
  "version": "0.1.0",
  "private": true,
  "dependencies": {
    "@material-ui/core": "^4.12.4",
    "@material-ui/icons": "^4.11.3",
    "@testing-library/jest-dom": "^5.16.4",
    "@testing-library/react": "^13.3.0",
    "@testing-library/user-event": "^13.5.0",
    "contentful": "^9.1.32",
    "gsap": "^3.10.4",
    "lil-gui": "^0.16.1",
    "react": "^18.2.0",
    "react-dom": "^18.2.0",
    "react-scripts": "5.0.1",
    "sass": "^1.53.0",
    "three": "^0.141.0",
    "web-vitals": "^2.1.4"
  },
  "scripts": {
    "start": "react-scripts start",
    "build": "react-scripts build",
    "test": "react-scripts test",
    "eject": "react-scripts eject"
  },
  "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": {
    "eslint": "^7.32.0 || ^8.2.0",
    "eslint-config-airbnb": "^19.0.4",
    "eslint-plugin-import": "^2.25.3",
    "eslint-plugin-jsx-a11y": "^6.5.1",
    "eslint-plugin-react": "^7.28.0",
    "eslint-plugin-react-hooks": "^4.3.0"
  }
}
ninja_nugget
  • 712
  • 1
  • 8
  • 19

1 Answers1

0

The best solution is simply to send a pull request to the github repository of the library. Else, you can fork the repository, apply the desired changes, and write this in your package json:

forked-lib": "https://github.com/<your-user-name>/forked-lib.git"

forked-lib is of course a generic name, please the replace the dummy values with proper information.

EDIT:

Sorry, I didn't see you use create react app. So, you need to eject the config files to modify them. Just run npm eject or yarn eject to do so. You will then have access to the webpack file, and it won't be ignored anymore.

Another possibility (not tested), would be to change your .gitignore file by excluding all node modules except webpack:

/node_modules\/(?!webpack$)/

But I'm not sure it will work properly.

DoneDeal0
  • 5,273
  • 13
  • 55
  • 114