generated from 4GeeksAcademy/react-hello-webapp
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwebpack.common.js
56 lines (55 loc) · 1.36 KB
/
webpack.common.js
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
const webpack = require("webpack");
const path = require("path");
const HtmlWebpackPlugin = require("html-webpack-plugin");
const Dotenv = require("dotenv-webpack");
module.exports = {
entry: ["./src/js/index.js"],
output: {
filename: "bundle.js",
path: path.resolve(__dirname, "build"), // Cambia 'public' a 'build'
publicPath: "/",
},
module: {
rules: [
{
test: /\.(js|jsx)$/,
exclude: /node_modules/,
use: ["babel-loader"],
},
{
test: /\.(css)$/,
use: [
{
loader: "style-loader", // crea nodos de estilo desde cadenas de JS
},
{
loader: "css-loader", // traduce CSS a CommonJS
},
],
},
// Para imágenes
{
test: /\.(png|svg|jpg|gif|jpeg|webp)$/,
use: {
loader: "file-loader",
options: { name: "[name].[ext]" },
},
},
// Para fuentes
{
test: /\.woff($|\?)|\.woff2($|\?)|\.ttf($|\?)|\.eot($|\?)|\.svg($|\?)/,
use: ["file-loader"],
},
],
},
resolve: {
extensions: ["*", ".js", ".jsx"], // Agrega '.jsx' para que Webpack reconozca las extensiones
},
plugins: [
new HtmlWebpackPlugin({
favicon: "4geeks.ico",
template: "template.html",
}),
new Dotenv({ safe: true, systemvars: true }),
],
};