-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathwebpack.config.js
122 lines (120 loc) · 3.39 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
/* eslint-disable no-unused-vars */
/* eslint-disable no-undef */
const path = require("path");
const webpack = require("webpack"); // to access built-in plugins
const { VueLoaderPlugin } = require("vue-loader");
const { CleanWebpackPlugin } = require("clean-webpack-plugin");
const MiniCssExtractPlugin = require("mini-css-extract-plugin");
const HtmlWebpackPlugin = require("html-webpack-plugin");
const NodePolyfillPlugin = require("node-polyfill-webpack-plugin");
const CssMinimizerPlugin = require("css-minimizer-webpack-plugin");
const TerserPlugin = require("terser-webpack-plugin");
const devMode = process.env.NODE_ENV !== "production";
const ASSET_PATH = process.env.ASSET_PATH || "";
module.exports = {
entry: "./src/app/index.js",
output: {
path: path.resolve(__dirname, "src/public"),
filename: "js/[name].js",
assetModuleFilename: "assets/img/[name].[ext][query]",
publicPath: "",
},
resolve: {
extensions: [".js", ".vue"],
},
module: {
rules: [
{
test: /\.vue$/,
loader: "vue-loader",
exclude: /node_modules/,
},
{
test: /\.(js|jsx)?$/,
loader: "babel-loader",
exclude: /node_modules/,
},
{
test: /\.(html)?$/,
loader: "html-loader",
exclude: /node_modules/,
},
{
test: /\.(sa|sc|c)ss$/,
exclude: /node_modules/,
use: [
devMode ? "style-loader" : MiniCssExtractPlugin.loader,
"css-loader",
{
loader: "sass-loader",
options: {
implementation: require("sass"),
},
},
],
},
{
test: /\.(png|svg|jpg|jpeg|gif)$/i,
type: "asset/resource",
exclude: /node_modules/,
},
{
test: /\.(woff|woff2)$/,
exclude: /node_modules/,
use: {
loader: "url-loader",
options: {
// limit => limite de tamaño
limit: 10000,
// Mimetype => tipo de dato
mimetype: "application/font-woff",
// name => nombre de salida
name: "[name].[ext]",
// outputPath => donde se va a guardar en la carpeta final
outputPath: "./assets/fonts/",
publicPath: "./assets/fonts/",
esModule: false,
},
},
},
],
},
plugins: [
new VueLoaderPlugin(),
new MiniCssExtractPlugin({
filename: "css/[name].css",
chunkFilename: "css/[id].css",
}),
new NodePolyfillPlugin(),
new CleanWebpackPlugin(),
new HtmlWebpackPlugin({
template: path.resolve(__dirname, "./src/app/index.html"),
ninify: {
collapseWhitespace: true,
removeComments: true,
removeRedundantAttributes: true,
removeScriptTypeAttributes: true,
removeStyleLinkAttributes: true,
useShortDoctype: true,
},
}),
new webpack.DefinePlugin({
"process.env.ASSET_PATH": JSON.stringify(ASSET_PATH),
}),
],
optimization: {
minimize: true,
minimizer: [new CssMinimizerPlugin(), new TerserPlugin()],
},
experiments: {
topLevelAwait: true,
},
devServer: {
hot: true,
host: "0.0.0.0",
compress: true,
port: 8000,
historyApiFallback: true,
},
// devtool: "eval",
};