first commit
This commit is contained in:
83
bundler/webpack.common.js
Normal file
83
bundler/webpack.common.js
Normal file
@@ -0,0 +1,83 @@
|
||||
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")
|
||||
}
|
||||
},
|
||||
};
|
||||
83
bundler/webpack.common_bk.js
Normal file
83
bundler/webpack.common_bk.js
Normal file
@@ -0,0 +1,83 @@
|
||||
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")
|
||||
}
|
||||
},
|
||||
};
|
||||
20
bundler/webpack.dev.js
Normal file
20
bundler/webpack.dev.js
Normal file
@@ -0,0 +1,20 @@
|
||||
const commonConfiguration = require('./webpack.common.js');
|
||||
|
||||
module.exports = {
|
||||
...commonConfiguration,
|
||||
mode: 'development',
|
||||
watch: true,
|
||||
watchOptions: {
|
||||
ignored: /node_modules/,
|
||||
aggregateTimeout: 300,
|
||||
poll: 1000,
|
||||
},
|
||||
devServer: {
|
||||
host: '0.0.0.0',
|
||||
static: './dist',
|
||||
liveReload: true,
|
||||
open: true,
|
||||
allowedHosts: 'all',
|
||||
https: false
|
||||
},
|
||||
};
|
||||
79
bundler/webpack.prod.js
Normal file
79
bundler/webpack.prod.js
Normal file
@@ -0,0 +1,79 @@
|
||||
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'],
|
||||
},
|
||||
],
|
||||
},
|
||||
};
|
||||
Reference in New Issue
Block a user