Я предоставлю вам инструкции по созданию файла webpack.config.js в корневом каталоге и добавлению в него необходимого кода. Вот шаги:
- Откройте текстовый редактор и создайте новый файл.
- Сохраните файл как «webpack.config.js» в корневом каталоге вашего проекта.
Теперь вы можете добавить следующий код в файл webpack.config.js:
const path = require('path');
module.exports = {
entry: './src/index.js', // Specify the entry point of your application
output: {
path: path.resolve(__dirname, 'dist'), // Specify the output directory
filename: 'bundle.js' // Specify the output file name
},
module: {
rules: [
{
test: /\.js$/, // Apply the following loaders to JavaScript files
exclude: /node_modules/,
use: {
loader: 'babel-loader' // Use Babel loader to transpile JavaScript files
}
},
{
test: /\.css$/, // Apply the following loaders to CSS files
use: ['style-loader', 'css-loader'] // Use style-loader and css-loader to handle CSS files
}
]
},
devServer: {
contentBase: path.resolve(__dirname, 'dist'), // Specify the directory to serve static files from
port: 3000, // Specify the port number to run the development server on
open: true // Automatically open the application in the browser
}
};
Эти инструкции предполагают, что вы уже установили веб-пакет и связанные с ним зависимости в своем проекте.