-
Notifications
You must be signed in to change notification settings - Fork 0
/
webpack.config.prod.js
116 lines (104 loc) · 2.41 KB
/
webpack.config.prod.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
const webpack = require('webpack');
const fs = require('fs');
const path = require('path');
const autoprefixer = require('autoprefixer');
const MiniCssExtractPlugin = require('mini-css-extract-plugin');
const HtmlWebpackPlugin = require('html-webpack-plugin');
module.exports = {
entry: {
app: './src/main.js',
},
mode: 'production',
module: {
rules: [
{
test: /\.js$/,
use: [
{
loader: 'babel-loader',
},
],
exclude: /node_modules/,
},
{
test: /\.scss$/,
use: [
'style-loader',
MiniCssExtractPlugin.loader,
'css-loader',
{
loader: 'postcss-loader',
options: {
plugins() {
return [
autoprefixer({
browsers: ['> 1%', 'last 2 versions'],
}),
];
},
},
},
'sass-loader',
'import-glob-loader',
],
},
{
test: /\.(png|jpe?g|gif|webm|mp4|ogv|txt|mp3|ogg|wav|pdf)$/,
loader: 'file-loader',
options: {
context: path.resolve(__dirname, './src'),
name: '[path][name].[ext]',
},
},
{
test: /\.pug$/,
use: [
{
loader: 'html-loader',
options: {
attrs: ['img:src', 'img:srcset', 'source:src', 'source:srcset'],
removeComments: false,
},
},
{
loader: path.resolve('pug-html-loader'),
options: {
exports: false,
data: {
fs,
process: {
env: {
NODE_ENV: 'production',
},
},
},
},
},
],
},
{
test: /\.(eot|otf|woff|woff2|ttf|svg)$/,
use: ['url-loader?name=fonts/[name].[ext]'],
},
],
},
plugins: [
new HtmlWebpackPlugin({
favicon: './favicon.png',
title: 'Rumo ao 10',
template: path.join('./src', 'index.pug'),
}),
new MiniCssExtractPlugin({
filename: 'main.css',
}),
new webpack.LoaderOptionsPlugin({
minimize: true,
debug: false,
}),
],
output: {
filename: 'bundle.js',
path: path.resolve('dist'),
publicPath: './',
},
};