49 lines
1.0 KiB
JavaScript
49 lines
1.0 KiB
JavaScript
const path = require('path');
|
|
const HtmlWebpackPlugin = require('html-webpack-plugin');
|
|
// 1. Require the plugin
|
|
const CopyWebpackPlugin = require('copy-webpack-plugin');
|
|
|
|
module.exports = {
|
|
entry: './src/main.js',
|
|
output: {
|
|
filename: 'bundle.[contenthash].js',
|
|
path: path.resolve(__dirname, 'dist'),
|
|
clean: true,
|
|
},
|
|
resolve: {
|
|
alias: {
|
|
'@': path.resolve(__dirname, 'src'),
|
|
},
|
|
},
|
|
module: {
|
|
rules: [
|
|
{
|
|
test: /\.js$/,
|
|
exclude: /node_modules/,
|
|
use: {
|
|
loader: 'babel-loader',
|
|
},
|
|
},
|
|
],
|
|
},
|
|
plugins: [
|
|
new HtmlWebpackPlugin({
|
|
template: 'index.html',
|
|
}),
|
|
// 2. Add the plugin with configuration patterns
|
|
new CopyWebpackPlugin({
|
|
patterns: [
|
|
{
|
|
from: 'assets', // Source directory of your assets
|
|
to: 'assets' // Target folder inside 'dist'
|
|
},
|
|
],
|
|
}),
|
|
],
|
|
devServer: {
|
|
static: path.resolve(__dirname, 'dist'),
|
|
port: 8080,
|
|
hot: true,
|
|
},
|
|
};
|