-
-
Notifications
You must be signed in to change notification settings - Fork 57
Expand file tree
/
Copy pathwebpack.config.js
More file actions
88 lines (80 loc) · 2.29 KB
/
webpack.config.js
File metadata and controls
88 lines (80 loc) · 2.29 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
const path = require('path');
const HtmlWebpackPlugin = require('html-webpack-plugin');
const MiniCssExtractPlugin = require('mini-css-extract-plugin');
const CopyWebpackPlugin = require('copy-webpack-plugin');
const webpack = require('webpack');
const packageJson = require('./package.json');
module.exports = {
mode: process.env.NODE_ENV || 'development',
entry: './src/index.js', // Archivo de entrada principal
output: {
path: path.resolve(__dirname, 'dist'),
filename: 'bundle.js',
},
plugins: [
new HtmlWebpackPlugin({
template: './src/index.html', // Path a tu HTML original
filename: 'index.html' // El HTML generado irá a 'dist/index.html'
}),
new MiniCssExtractPlugin({
filename: 'styles.css',
}),
new CopyWebpackPlugin({
patterns: [
{
from: 'assets/images', // ajusta esta ruta a donde tengas tus imágenes
to: 'assets/images'
},
{
from: 'src/data',
to: 'data'
}
]
}),
new webpack.DefinePlugin({
APP_VERSION: JSON.stringify(packageJson.version),
BUILD_ID: JSON.stringify(
process.env.BUILD_ID ||
process.env.VERCEL_DEPLOYMENT_ID ||
'local'
),
'process.env.NODE_ENV': JSON.stringify(process.env.NODE_ENV),
'process.env.PATREON_CLIENT_ID': JSON.stringify(process.env.PATREON_CLIENT_ID),
'process.env.PATREON_REDIRECT_URI': JSON.stringify(process.env.PATREON_REDIRECT_URI),
})
],
resolve: {
extensions: ['.js'],
fallback: {
// Si tu código usa 'buffer' (p.ej. new Buffer o Buffer.from)
buffer: require.resolve('buffer/'),
"vm": false,
"stream": false,
"fs": false,
"path": false,
"crypto": false,
},
},
module: {
rules: [
{
test: /\.js$/,
exclude: /node_modules/,
use: {
loader: 'babel-loader',
},
},
{
test: /\.css$/i,
use: [MiniCssExtractPlugin.loader, 'css-loader'], // Usa el plugin en lugar de 'style-loader'
},
{
test: /\.(png|jpe?g|gif|svg)$/i,
type: 'asset/resource',
generator: {
filename: 'assets/images/[name][ext]', // Copia las imágenes en dist/assets/images
},
},
],
},
};