const commonConfiguration = require('./webpack.common.js'); const { CleanWebpackPlugin } = require('clean-webpack-plugin'); const HtmlWebpackPlugin = require('html-webpack-plugin'); const { ProvidePlugin } = require('webpack'); const CopyWebpackPlugin = require('copy-webpack-plugin'); const path = require('path'); module.exports = { // ...commonConfiguration, mode: 'production', entry: path.resolve(__dirname, '../src/index.js'), output: { filename: 'bundle.[hash].js', path: path.resolve(__dirname, '../dist'), }, plugins: [ new CleanWebpackPlugin(), new ProvidePlugin({ $: 'jquery', // Rende $ disponibile globalmente jQuery: 'jquery', 'window.jQuery': 'jquery', }), new HtmlWebpackPlugin({ template: path.resolve(__dirname, '../src/index.html'), minify: true }), new CopyWebpackPlugin({ patterns: [ { from: path.resolve(__dirname, '../static') }, { from: 'src/assets', to: 'assets' }, ], }), ], module: { rules: [ // HTML { test: /\.(html)$/, use: ['html-loader'], }, // JS { test: /\.js$/, exclude: /node_modules/, use: ['babel-loader'], }, // CSS { test: /\.css$/, use: ['style-loader', 'css-loader'], }, // Images { test: /\.(jpg|png|gif|svg)$/, type: 'asset/resource', generator: { filename: 'assets/images/[name].[hash][ext][query]', }, }, // Fonts { test: /\.(woff|woff2)$/, type: 'asset/resource', generator: { filename: 'assets/fonts/[name].[hash][ext][query]', }, }, // Shaders { test: /\.(glsl|vs|fs|vert|frag)$/, exclude: /node_modules/, use: ['raw-loader', 'glslify-loader'], }, ], }, };