-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwebpack.config.js
70 lines (69 loc) · 1.87 KB
/
webpack.config.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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
// webpack.config.js
const path = require("path");
const HtmlWebpackPlugin = require("html-webpack-plugin");
const { CleanWebpackPlugin } = require("clean-webpack-plugin");
const MiniCssExtractPlugin = require("mini-css-extract-plugin");
module.exports = {
devtool: "inline-source-map",
entry: {
main: "./src/pages/index.js",
},
output: {
path: path.resolve(__dirname, "dist"),
filename: "main.js",
publicPath: "/",
},
target: ["web", "es5"],
stats: { children: true },
mode: "development",
devServer: {
static: path.resolve(__dirname, "./dist"),
compress: true,
port: 8082,
open: true,
},
module: {
rules: [
// esto es un array de reglas
// añádele un objeto que contenga reglas para Babel
{
// una expresión regular que busca todos los archivos js
test: /\.js$/,
// todos los archivos deben ser procesados por babel-loader
loader: "babel-loader",
// excluye la carpeta node_modules, no necesitamos procesar archivos en ella
exclude: "/node_modules/",
},
{
test: /\.css$/,
use: [
MiniCssExtractPlugin.loader,
{
loader: "css-loader",
options: {
importLoaders: 1,
},
},
"postcss-loader",
],
},
{
// añade la regla para el procesamiento de archivos
test: /\.(png|svg|jpg|gif|woff(2)?|eot|ttf|otf)$/,
type: "asset/resource",
},
],
},
plugins: [
new HtmlWebpackPlugin({
template: "./src/index.html", // ruta a nuestro archivo index.html
}),
new CleanWebpackPlugin(),
new MiniCssExtractPlugin(), // conecta el plugin para fusionar archivos CSS
],
resolve: {
alias: {
"@": path.resolve(__dirname, "src"), // Add this line to create an alias for the 'src' folder
},
},
};