6

i have a react project with the following package.json :

    {
  "name": "commonsensev2.0",
  "version": "0.1.0",
  "private": true,
  "homepage": "http://localhost:9080/server/react",
  "dependencies": {
    "all": "0.0.0",
    "axios": "^0.18.0",
    "babel-polyfill": "^6.26.0",
    "chart.js": "^2.7.3",
    "moment": "^2.23.0",
    "node-sass-chokidar": "0.0.3",
    "npm-run-all": "^4.1.5",
    "popper.js": "^1.14.6",
    "react": "^16.7.0",
    "react-bootstrap": "^0.31.5",
    "react-bootstrap-table": "^4.3.1",
    "react-chartjs2": "^1.2.1",
    "react-dom": "^16.7.0",
    "react-localize-redux": "^2.17.5",
    "react-moment": "^0.7.9",
    "react-redux": "^5.1.1",
    "react-router-dom": "^4.3.1",
    "react-scripts": "1.0.14",
    "redux": "^3.7.2"
  },
  "scripts": {
    "build-css": "node-sass-chokidar src/sass/App.scss -o src/css/",
    "watch-css": "npm run build-css && node-sass-chokidar src/sass/App.scss -o src/css/ --watch --recursive",
    "start-js": "react-scripts start",
    "start": "npm-run-all -p watch-css start-js",
    "build": "npm run build-css && react-scripts build",
    "postbuild": "((ROBOCOPY build ../react /MIR) ^& if %ERRORLEVEL% lss 8 set ERRORLEVEL = 0)",
    "test": "react-scripts test --env=jsdom",
    "eject": "react-scripts eject"
  },
  "devDependencies": {
    "bootstrap-toggle": "^2.2.2",
    "datatables.net": "^1.10.19",
    "numeral": "^2.0.6"
  }
}

when i do npm run build i cannot see the changes on the html pages, i m using node 8.11.1 i downgraded it because i found somewhere that it maybe the reason why it does not work i'm also using "node-sass-chokidar": "0.0.3" and the backend is a java server

hamzan
  • 121
  • 1
  • 2
  • 6
  • Is it that your html does not update during development? – Dejan.S Jan 03 '19 at 14:27
  • yes, exactly when i run npm run build nothing changes in the html content – hamzan Jan 03 '19 at 14:29
  • Is Build-css generating .css? How do you import the css into the react? I do something similar, but I use sass. – Chance Jan 03 '19 at 14:36
  • @AndersonMendes i use also sass for the css import – hamzan Jan 03 '19 at 14:40
  • Sorry I Expressed Wrong, I use `npm sass` to compile scss to css and then import the css direct into root Example: `"sass:build": "sass --update src/styles/scss:src/styles/css"` in reactjs root `import '../styles/css/component.css'` – Chance Jan 03 '19 at 14:57

2 Answers2

5

I had the same issue, I deleted the old build folder on my local environment and ran npm run build again to generate a new build folder.

tassmanian
  • 51
  • 1
  • 4
1

Just a wild guess here but I think you are running the wrong command. Because build is typically when you want to build code for a purpose like putting it on a server.

What you need to do is to npm run start, as that has the watch, that watches for changes and updates.

Just a minor thing, I would rename the start script to dev or serve. Generally more used I would say.

Dejan.S
  • 18,571
  • 22
  • 69
  • 112
  • well i'm building code for the purpose of putting it on a server, it's just when i do npm run build to generate updated versions of the css and js and html it does not chow those changes – hamzan Jan 03 '19 at 19:10
  • @hamzan ok that is a different thing then the development I asked about before :). I had the same issue before I just need some time to refresh my memory about what I did. – Dejan.S Jan 04 '19 at 08:27
  • much appreciated, take your time – hamzan Jan 04 '19 at 13:49