-
Notifications
You must be signed in to change notification settings - Fork 0
/
webpack.mix.js
166 lines (152 loc) · 3.89 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
160
161
162
163
164
165
166
let mix = require('laravel-mix')
require('laravel-mix-purgecss')
let scssOptions = {
processCssUrls: true,
fileLoaderDirs: {
images: '/assets/images',
fonts: '/assets/fonts'
}
}
let bundles = {
'all': [
'./src/js/app.js'
]
}
let extractLibs = [
'jquery',
'bootstrap',
]
const purgecssWordpress = {
whitelist: [
'rtl',
'home',
'blog',
'archive',
'date',
'error404',
'logged-in',
'admin-bar',
'no-customize-support',
'custom-background',
'wp-custom-logo',
'pagination',
'alignnone',
'alignright',
'alignleft',
'wp-caption',
'wp-caption-text',
'screen-reader-text',
'comment-list',
],
whitelistPatterns: [
/^rtl(-.*)?$/,
/^home(-.*)?$/,
/^blog(-.*)?$/,
/^archive(-.*)?$/,
/^date(-.*)?$/,
/^error404(-.*)?$/,
/^logged-in(-.*)?$/,
/^admin-bar(-.*)?$/,
/^no-customize-support(-.*)?$/,
/^search(-.*)?$/,
/^nav(-.*)?$/,
/^wp(-.*)?$/,
/^wp-block-(a-z)?$/,
/^wp-custom-logo(-.*)?$/,
/^screen(-.*)?$/,
/^navigation(-.*)?$/,
/^(.*)-template(-.*)?$/,
/^(.*)?-?single(-.*)?$/,
/^postid-(.*)?$/,
/^post-(.*)?$/,
/^attachmentid-(.*)?$/,
/^attachment(-.*)?$/,
/^page(-.*)?$/,
/^(post-type-)?archive(-.*)?$/,
/^author(-.*)?$/,
/^gallery(-.*)?$/,
/^category(-.*)?$/,
/^tag(-.*)?$/,
/^card(-.*)?$/,
/^menu(-.*)?$/,
/^tags(-.*)?$/,
/^tax-(.*)?$/,
/^term-(.*)?$/,
/^date-(.*)?$/,
/^(.*)?-?paged(-.*)?$/,
/^says(-.*)?$/,
/^depth(-.*)?$/,
/^comment(-.*)?$/,
/^comments(-.*)?$/,
/^children(-.*)?$/,
/^crnb(-.*)?$/,
/^custom(-.*)?$/,
/^custom-background(-.*)?$/,
/^port-description(-.*)?$/,
/^gform_(.*)?$/,
/^gfield_(.*)?$/,
/^validation_(.*)?$/
],
}
mix.setResourceRoot('../../')
.setPublicPath('./')
.sass('src/scss/base.scss', 'assets/css').options(scssOptions)
// Extract libraries requires ECMAScript 6 imports in your code.
// .js(bundles.all, 'assets/js/app.js').extract(extractLibs)
.js(bundles.all, 'assets/js/app.js')
.extract( extractLibs )
.purgeCss(
{
// enabled: mix.inProduction(),
enabled: false,
paths: () => [
path.join(__dirname, '*.php'),
path.join(__dirname, 'templates/**/*.php'),
path.join(__dirname, 'assets/js/**/*.js')
],
extensions: ['html', 'js', 'php'],
// Other options are passed through to Purgecss
whitelist: purgecssWordpress.whitelist,
whitelistPatterns: purgecssWordpress.whitelistPatterns,
}
)
.autoload({
'jquery': ['$', 'window.jQuery', 'jQuery']
})
.version()
// Production
if (mix.inProduction()) {
mix.options({
terser: {
terserOptions: {
warnings: true
}
}
})
} else {
mix.webpackConfig({
devtool: 'source-map',
})
mix.sourceMaps()
}
// BrowserSync and LiveReload on `npm run watch` command
//mix.browserSync({
// proxy: 'http://wordpress.local',
// port: 8080,
// If you want to use HTTPS, update the proxy path
// and add tour local certificate paths
// https: {
// key: '/your/certificates/location/your-local-domain.key',
// cert: '/your/certificates/location/your-local-domain.crt'
// },
// files: [
// '**/*.php',
// 'assets/css/**/*.css',
// 'assets/js/**/*.js',
// '!node_modules',
// '!vendor',
// ],
// ghostMode: false,
// open: false,
// injectChanges: true,
//})