1

I am new to npm build tools. I want to bundle the compiled typescript files as soon as there is a change in typescript files and run lite-server concurrently. To achieve that I have written following npm build script -

"build": "tsc",
"bundle": "browserify -s main app/goc-common/common.module.js > dist/bundle.js", 
"build_dev": "npm run build && npm run bundle && concurrently \"tsc -w && npm run bundle\" \"lite-server\"",

However this doesn't seems to work, it just compiles the files and refresh the browser, donot bundle the files again.

codeomnitrix
  • 4,179
  • 19
  • 66
  • 102

1 Answers1

2

You should use watchify to continue watching tsc's output files for changes:

"build": "tsc",
"bundle": "watchify -s main app/goc-common/common.module.js -o dist/bundle.js",
"build_dev": "npm run build && npm run bundle && concurrently \"tsc -w && npm run bundle\" \"lite-server\""

As you've noticed, browserify doesn't watch; it just runs once and then it's done. watchify's usage is identical to browserify's, except that the -o option is mandatory.

cartant
  • 57,105
  • 17
  • 163
  • 197