-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwebpack.config.js
128 lines (125 loc) · 3.86 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
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
//Vamos a usar el paquete path para que las rutas sean válidas tanto en windows como en linux
var path = require("path");
var HtmlWebPackPlugin = require("html-webpack-plugin");
var entryPath = path.join(__dirname, "src");
var outPath = path.join(__dirname, "dist");
var CopyPlugin = require('copy-webpack-plugin');
//Vamos a usar este plugin para combinar todos los ficheros scss
const MiniCssExtractPlugin = require("mini-css-extract-plugin");
module.exports = {
entry: [path.join(entryPath, "app.js")],
output: {
path: outPath,
filename: "bundle.js"
},
module: {
rules : [
{
test: /\.js$/,
include: entryPath,
use: [
{
loader: 'babel-loader',
}
]
},
{
test: /\.scss$/,
include: entryPath,
exclude: [path.join(entryPath, "defaults.scss"), path.join(entryPath, "imports.scss")],
use: [
MiniCssExtractPlugin.loader,
{
loader: 'css-loader',
options: {
modules: true,
sourceMap: true,
localIdentName: '[name]__[local]__[hash:base64:5]'
}
},
{
loader: 'sass-loader'
}
]
},
{
test: /defaults\.scss$/,
include: entryPath,
use: [
MiniCssExtractPlugin.loader,
{
loader: 'css-loader',
options: {
modules: false
}
},
{
loader: 'sass-loader'
}
]
},
{
test: /react-datepicker\.css$/,
include: path.join(__dirname, "node_modules", "react-datepicker", "dist"),
use: [
MiniCssExtractPlugin.loader,
{
loader: 'css-loader',
options: {
modules: false
}
}
]
},
{
test: /imports\.scss$/,
include: entryPath,
use: [
MiniCssExtractPlugin.loader,
{
loader: 'css-loader',
options: {
modules: false
}
},
{
loader: 'sass-loader'
}
]
},
{
test: /\.(png|jpg|gif)$/,
include: entryPath,
use: [
{
loader: 'file-loader',
options: {
outputPath: 'images/',
publicPath: 'images/',
},
},
],
},
]
},
devServer: {
contentBase: outPath
},
plugins: [
new MiniCssExtractPlugin({
filename: "styles.css",
chunkFilename: "styles.css"
}),
new HtmlWebPackPlugin({
title: "dpsToggl",
template: path.join(__dirname, "src", "index.html"),
filename: "index.html"
}),
new CopyPlugin([
{ from: "./node_modules/bootstrap/dist/js/bootstrap.bundle.min.js", to: "./lib/bootstrap" },
{ from: "./node_modules/jquery/dist/jquery.min.js", to: "./lib/jquery" },
{ from: "./node_modules/@fortawesome/fontawesome-free", to: "./lib/font_awesome" },
{ from: "./src/images/favicon.ico", to: "./" },
]),
]
}