I configure my react app with webpack service, after running webpack, i found issues that the web server is still running on the local port, i tries ctrl + C may times but still doesn't work until i killed that port.
Here's my webpack.config file
const { resolve } = require("path")
const HtmlWebpackPlugin = require('html-webpack-plugin')
const TeserWebpackPlugin = require('terser-webpack-plugin')
const { ModuleFederationPlugin } = require('webpack').container
const isProduct = process.env.NODE_ENV === 'production'
const config = {
mode: isProduct ? 'production' : 'development',
entry: {
main: './src/index.tsx'
},
output: {
path: resolve(__dirname, 'dist'),
filename: "bundle.js"
},
resolve: {
extensions: [".js", ".ts", ".tsx", ".jsx"]
},
module: {
rules: [
{
test: /\.tsx?$/,
use: "babel-loader",
exclude: '/node_modules/',
use: {
loader: "babel-loader",
options: {
presets: ["@babel/preset-env", "@babel/preset-react"],
},
},
}
]
},
plugins: [
new HtmlWebpackPlugin({
template: './src/index.html',
filename: 'index.html',
inject: 'body'
}),
new ModuleFederationPlugin(
{
name: 'practice',
filename: 'remoteEntry.js',
exposes: {
'./practice': './src/App.tsx',
},
},
),
]
}
config.output.filename = "static/js/[name].js";
if (isProduct) {
config.optimization = {
minimizer: [new TeserWebpackPlugin()],
}
}
else {
config.devServer = {
port: 3003,
open: true,
hot: true,
compress: true,
}
}
module.exports = config
After i run it, it compile successful and deploy on localhost:3003, but after stop the service by Ctrl + C, and when I re-check the port, it still running.
The command line say that my app compiled successfully, when I stop it, the port 3003 still work
Is there any attribute would force to kill the port after cancel or at least overwrite the port on the next compile, please help me
Here's my script I used to run the webpack app
"scripts": {
"dev": "cross-env NODE_ENV=development webpack-dev-server",
"build": "cross-env NODE_ENV=production webpack",
"start": "serve dist",
"test": "echo \"Error: no test specified\" && exit 1"
},