84 lines
2.2 KiB
JavaScript
84 lines
2.2 KiB
JavaScript
const CopyWebpackPlugin = require('copy-webpack-plugin');
|
|
const HtmlWebpackPlugin = require('html-webpack-plugin');
|
|
const { ProvidePlugin } = require('webpack');
|
|
|
|
const path = require('path');
|
|
|
|
module.exports = {
|
|
entry: path.resolve(__dirname, '../src/index.js'),
|
|
output: {
|
|
filename: 'bundle.[hash].js',
|
|
path: path.resolve(__dirname, '../dist'),
|
|
},
|
|
devtool: 'source-map',
|
|
plugins: [
|
|
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'],
|
|
},
|
|
],
|
|
},
|
|
resolve: {
|
|
alias: {
|
|
// Add any aliases here if needed
|
|
},
|
|
fallback: {
|
|
"path": require.resolve("path-browserify")
|
|
}
|
|
},
|
|
};
|