I've developed an Angular app using npm and web-pack, which is then served on a Tomcat web server.
When the command npm run build
is executed, all JS files are built into the /build
directory of the project. However, when running npm start
, it uses the /out
directory instead.
Is there a way to configure npm start
to use the /build
directory as well?
The reason for my inquiry: Currently, the JS content is served alongside the Java backend, resulting in no distinction between production and development runs (both utilize the same build folder). It would be beneficial to have consistency on the frontend side as well.
UPDATE: I managed to resolve the issue by adjusting the webpack configuration
Under the hood, npm start
executes webpack, which can be configured using a .js
script.
I have made changes to the section as follows:
output: {
path: helpers.root('../build'),
publicPath: '/',
filename: '[name].js',
chunkFilename: '[id].chunk.js'
}
This now points to the ./build
directory.