2

I have Angular app built with npm and web-pack served on Tomcat web server.

Command npm run build builds all JS files into /build directory of the project, but npm start uses /out directory.

Is there any way to force npm start using /build directory as well?

Why I need this: Currently JS content is served together with backend written with Java and there is no difference between production run and dev run (both use the same build folder). It would also be convenient to have the same on frontend side.

UPDATE: I've solved the problem by enhancing webpack config

npm start runs webpack under the hood which is configured via .js script.

I have updated section:

output: {
    path: helpers.root('../build'),
    publicPath: '/',
    filename: '[name].js',
    chunkFilename: '[id].chunk.js'
}

pointing to the ./build directory.

Sasha Shpota
  • 9,436
  • 14
  • 75
  • 148

1 Answers1

0

You can use concurrently for this, in your packages.json use something like:

"scripts": {
  "client": "cd build && npm start",
  "server": "cd out && npm start",
  "start": "concurrent \"npm run client\" \"npm run server\"",
},
"devDependencies": {
  "concurrently": "^3.5.0"
}
mega6382
  • 9,211
  • 17
  • 48
  • 69