-
Notifications
You must be signed in to change notification settings - Fork 5
/
webpack.mix.js
159 lines (154 loc) · 4.45 KB
/
webpack.mix.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
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
const mix = require('laravel-mix');
require('laravel-mix-purgecss');
require('laravel-mix-criticalcss');
require('laravel-mix-webp');
const path = require('path');
const SVGSpritemapPlugin = require('svg-spritemap-webpack-plugin');
let frontendImports = require('./resources/js/frontend-imports');
const httpRegex = 'http:\\/\\/|https:\\/\\/';
const projectProxy = process.env.APP_URL.replace(new RegExp(httpRegex), '');
/*
* USAGE
* <svg role="img">
* <use xlink:href="/svg/sprite.svg#050-santa-claus"></use>
* </svg>
* <svg role="img">
* <use xlink:href="/svg/sprite.svg#049-deer"></use>
* </svg>
* */
const wpConfig = {
plugins: [
new SVGSpritemapPlugin('resources/svg/sprite/*.svg', {
output: {
filename: 'svg/sprite.svg',
svgo: {
plugins: [
{ name: 'removeTitle', active: true },
{ name: 'convertColors', params: { currentColor: 'black' }},
],
},
chunk: {
name: '../resources/js/spritemap',
},
},
sprite: {
prefix: false,
},
}),
],
};
mix
.sass('resources/sass/frontend.scss', 'public/css')
.purgeCss({
extend: {
content: [
path.join(__dirname, 'packages/agenciafmd/frontend/src/**/*.php'),
path.join(__dirname, 'node_modules/@fancyapps/fancybox/dist/*.js'),
path.join(__dirname, 'node_modules/swiper/**/*.js'),
path.join(__dirname, 'node_modules/jquery/dist/jquery.min.js'),
path.join(__dirname, 'node_modules/select2/dist/**/*.js'),
path.join(__dirname, 'node_modules/sweetalert2/dist/*.js'),
path.join(__dirname, 'node_modules/wow.js/dist/*.js'),
path.join(
__dirname,
'node_modules/bootstrap/dist/js/bootstrap.min.js',
),
],
// Include classes we don't have direct access
safelist: [/hs-*/, /fancybox-*/, /js-*/, /swiper-*/, /swal2-*/, /file-upload-button*/],
},
})
.criticalCss({
enabled: mix.inProduction(),
paths: {
base: process.env.APP_URL + '/html/',
templates: 'public/css/critical/',
suffix: '',
},
urls: [
{"url":"index","template":"index"}
],
// fmd:criticalPath !! This comment should not be removed !!
dimensions: [
{
width: 375,
height: 667,
},
{
width: 1024,
height: 768,
},
{
width: 1280,
height: 720,
},
{
width: 1366,
height: 768,
},
{
width: 1920,
height: 1080,
},
],
ignore: ['@font-face'],
})
.options({
imgLoaderOptions: {
enabled: true,
gifsicle: {},
mozjpeg: {
quality: 85,
progressive: true,
},
optipng: {
enabled: false,
},
pngquant: {
quality: '85-90',
speed: 4,
},
svgo: {},
},
processCssUrls: false,
})
.copy('resources/fonts', 'public/fonts')
.ImageWebp({
from: 'resources/images',
to: 'resources/images',
imageminWebpOptions: {
quality: 95
}
})
.copy('resources/images/**', 'public/images')
.copy('resources/svg/*.svg', 'public/svg')
.copy('resources/images/icons/favicon.ico', 'public')
.copy('resources/js/pwa/manifest.json', 'public')
.copy('resources/js/pwa/pwa-manager.js', 'public')
.babel(frontendImports, 'public/js/frontend.js')
.sourceMaps(false, 'source-map')
.browserSync({
host: '192.168.10.10',
proxy: projectProxy,
open: false,
watch: true,
files: [
'app/**/*.php',
'resources/views/**/*.php',
'packages/agenciafmd/frontend/src/**/*.php',
'public/css/**/*.css',
'public/fonts/*',
'public/images/*',
'public/js/**/*.js',
'public/json/*',
'public/svg/*',
],
watchOptions: {
usePolling: true,
interval: 500,
},
})
.webpackConfig(wpConfig);
if (mix.inProduction()) {
mix.version();
}