Using WebPack with Cocos

Hello,

I am trying to use WebPack with Cocos. Is there a documentation on how to do so ? I have tried with installing all the dependencies.

I have edited the package.json -

{
“name”: “newproject”,
“uuid”: “6520ed65-48d8-4a34-8ee5-ec382e9957af”,
“scripts”: {
“build”: “webpack --config webpack.config.js”
},
“creator”: {
“version”: “3.8.3”
},
“dependencies”: {
“cors”: “^2.8.5”
},
“devDependencies”: {
@types/fs-extra”: “^11.0.4”,
“css-loader”: “^7.1.2”,
“file-loader”: “^6.2.0”,
“ts-loader”: “^9.5.1”,
“webpack”: “^5.91.0”,
“webpack-cli”: “^5.1.4”
},
“contributions”: {}
}

My webpack.config.js

const path = require(‘path’);
module.exports = {
mode: ‘development’,
**entry: ‘./’, // What should be the entry for Cocos ?
output: {
filename: ‘bundle.js’,
path: path.resolve(__dirname, ‘dist’),
},
module: {
rules: [
{
test: /.ts$/,
use: ‘ts-loader’,
exclude: /node_modules/,
},
{
test: /.css$/,
use: [‘style-loader’, ‘css-loader’],
},
{
test: /.(png|jpg|gif|svg)$/,
use: [
{
loader: ‘file-loader’,
options: {
name: ‘[name].[ext]’,
outputPath: ‘assets/’,
},
},
],
},
],
},
resolve: {
extensions: [‘.ts’, ‘.js’],
},
};

When I run npm run build - I get the following errors. My entry field is a directory. What should be the entry file in a cocos project ?
Note - When I give a .ts file from the assets folder, I get the “TypeScript emitted no output” error for that file.

Is there a way to run webpack for Cocos ? Are there documentations ? Thanks!