|-- src
|-- index.css
|-- index.html
|-- index.js
|-- assets
|-- images
const path = require('path');
const HtmlWebpackPlugin = require('html-webpack-plugin');
const MiniCssExtractPlugin = require('mini-css-extract-plugin');
module.exports = {
devtool: 'eval-source-map',
mode: 'production',
output: {
path: path.resolve(__dirname, 'dist'),
clean: true,
},
module: {
rules: [
{
test: /.css$/,
use: [MiniCssExtractPlugin.loader, 'css-loader']
},
{
test: /.(png|svg|jpe?g|gif)$/,
type: 'asset',
generator: {
filename: 'assets/images/[name][ext][query]'
},
},
{
test: /.html$/,
loader: 'html-loader'
}
],
},
plugins: [
new MiniCssExtractPlugin({ filename: 'css/[contenthash].css' }),
new HtmlWebpackPlugin({
template: './src/index.html',
}),
],
devServer: {
static: {
directory: path.join(__dirname, 'public')
},
hot: true,
compress: true,
port: 9000,
},
performance: {
hints: false
}
};
"scripts": {
"build": "npx webpack",
"start":"webpack server"
},