-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwebpack.config.js
111 lines (111 loc) · 2.9 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
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
/*
./webpack.config.js
*/
const path = require("path"); // path utility
const HtmlWebpackPlugin = require("html-webpack-plugin");
// init HTML Webpack Plugin
const HtmlWebpackPluginConfig = new HtmlWebpackPlugin({
template: "./public/index.html", // archivo de nuestra vista
inject: "body", // donde insertaremos nuestro script
favicon: "./public/logo-r.ico",
});
const config = {
entry: ["babel-polyfill", "./src/index.js"], // archivo js que codearemos
output: {
path: path.resolve("./public"), //resolver el path de salida
filename: "bundle.js", // archivo js compilado
// publicPath: "/public/"
},
module: {
rules: [
{
test: /\.md$/,
use: [
{
loader: "html-loader",
},
{
loader: "webpack-md-loader",
options: {
html: true,
},
},
],
},
{
test: /\.js$/,
use: "babel-loader",
exclude: /node_modules/,
},
{
test: /\.jsx$/,
use: "babel-loader",
exclude: /node_modules/,
},
{
test: /\.css$/i,
use: ["style-loader", "css-loader"],
},
{
test: /\.svg$/,
loader: "svg-inline-loader",
},
{
test: /\.(scss)$/,
use: [
{
loader: "style-loader", // inject CSS to page
},
{
loader: "css-loader", // translates CSS into CommonJS modules
},
{
loader: "postcss-loader", // Run post css actions
options: {
plugins: function () {
// post css plugins, can be exported to postcss.config.js
return [require("precss"), require("autoprefixer")];
},
},
},
{
loader: "sass-loader", // compiles Sass to CSS
},
],
},
{
test: /\.(png|jpe?g|gif|svg|ttf|woff(2)?|ico)$/i,
exclude: /node_modules/,
use: [
{
loader: "file-loader",
options: {
outputPath: "assets",
esModule: false,
},
},
],
},
],
},
resolve: {
extensions: [".js", ".jsx"],
alias: {
"@config": path.resolve(__dirname, "src/config"),
"@styles": path.resolve(__dirname, "src/styles"),
"@utils": path.resolve(__dirname, "src/utils"),
"@fonts": path.resolve(__dirname, "src/fonts"),
"@components": path.resolve(__dirname, "src/components"),
"@data": path.resolve(__dirname, "src/data"),
},
},
plugins: [
HtmlWebpackPluginConfig,
// new HtmlWebpackPlugin({
// template: "./public/index.html",
// filename: "./index.html",
// favicon: "./public/favicon.ico"
// })
], // configuración de nuestra vista
};
module.exports = config; //exportamos a webpack nuestra configuración