-
Notifications
You must be signed in to change notification settings - Fork 1
/
webpack.mix.js
140 lines (139 loc) · 4.37 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
const mix = require( 'laravel-mix' );
const tailwindcss = require( 'tailwindcss' )( './tailwind.config.js' );
const purgecssWordpress = require( 'purgecss-with-wordpress' );
const purgecssFlickity = {
whitelist: [ 'dot' ],
whitelistPatterns: [ /^flickity/ ],
};
const purgecssFoundation6 = {
whitelist: [ 'js-off-canvas-overlay', 'is-closed', 'is-open', 'is-visible', 'is-closable', 'data-content-scroll' ],
whitelistPatterns: [
/^is-open(-.*)?$/,
/^is-overlay(-.*)?$/,
/^has-transition(-.*)?$/,
/^has-position(-.*)?$/,
/^is-off-canvas(-.*)?$/,
/^is-transition(-.*)?$/,
],
};
const purgecssWordpressAdditional = {
whitelist: [
'wp-admin',
'alignfull', 'alignwide',
'a', 'ul', 'ol', 'li', 'blockquote', 'dl', 'dd', 'h1', 'h2', 'h3', 'h4', 'h5', 'h6', 'figure', 'p', 'pre',
'img', 'svg', 'video', 'canvas', 'audio', 'iframe', 'embed', 'object',
],
whitelistPatterns: [
/^rtl(-.*)?$/,
/^home(-.*)?$/,
/^blog(-.*)?$/,
/^archive(-.*)?$/,
/^date(-.*)?$/,
/^error404(-.*)?$/,
/^logged-in(-.*)?$/,
/^admin-bar(-.*)?$/,
/^no-customize-support(-.*)?$/,
/^wp-custom-logo(-.*)?$/,
/^search(-.*)?$/,
/^nav(-.*)?$/,
/^wp(-.*)?$/,
/^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(-.*)?$/,
/^edit-/,
/^editor-/,
/^block-/,
/^hover/,
/^has/,
/^is-open/,
/^is-style/,
/^reveal-overlay$/,
/^current[-_]/,
/^jp/, // Jetpack stuff
],
};
const purgecss = require( '@fullhuman/postcss-purgecss' )( {
content: [
'./*.php',
'inc/**/*.php',
'assets/js/**/*.js',
'assets/js/**/*.jsx',
'views/**/*.twig',
],
whitelist: [ ...purgecssWordpress.whitelist, ...purgecssFlickity.whitelist, ...purgecssWordpressAdditional.whitelist, ...purgecssFoundation6.whitelist ],
whitelistPatterns: [ ...purgecssWordpress.whitelistPatterns, ...purgecssFlickity.whitelistPatterns, ...purgecssWordpressAdditional.whitelistPatterns, ...purgecssFoundation6.whitelistPatterns ],
defaultExtractor: ( content ) => content.match( /[A-Za-z0-9-_:/]+/g ) || [],
} );
/*
|--------------------------------------------------------------------------
| Mix Asset Management (this is borrowed from Laravel)
|--------------------------------------------------------------------------
|
| Mix provides a clean, fluent API for defining some Webpack build steps
| for your Laravel application. By default, we are compiling the Sass
| file for the application as well as bundling up all the JS files.
|
| For Details of the configuration, take a look at Laravel-mix project:
| https://laravel-mix.com/
*/
const postCss = mix.inProduction() ? [ tailwindcss, purgecss ] : [ tailwindcss ];
mix.webpackConfig( {
externals: {
'@wordpress/element': [ 'wp', 'element' ],
'@wordpress/plugins': [ 'wp', 'plugins' ],
'@wordpress/blocks': [ 'wp', 'blocks' ],
'@wordpress/edit-post': [ 'wp', 'editPost' ],
'@wordpress/i18n': [ 'wp', 'i18n' ],
'@wordpress/editor': [ 'wp', 'editor' ],
'@wordpress/components': [ 'wp', 'components' ],
'@wordpress/blob': [ 'wp', 'blob' ],
'@wordpress/data': [ 'wp', 'data' ],
'@wordpress/html-entities': [ 'wp', 'htmlEntities' ],
'@wordpress/compose': [ 'wp', 'compose' ],
jquery: [ 'window', 'jQuery' ],
},
} )
.sass( 'assets/scss/style.scss', 'dist/css/' )
.sass( 'assets/scss/style-editor.scss', 'dist/css/' )
.sass( 'assets/scss/style-shared.scss', 'dist/css/' )
// .react('assets/js/gutenberg/editor-extension/featured-posts.js', 'dist/js/featured-posts.js')
.js( 'assets/js/main.js', 'dist/js/main.js' )
.copyDirectory( 'assets/images/', 'dist/images/' )
.browserSync( {
proxy: 'localhost:8080', // your WP instance URL here
files: [ '*.php', '*.twig', '*.js', 'dist/', 'inc/', 'views/' ],
open: 'ui',
ghostMode: false, // mirror clicks, scrolls & form inputs on all connected devices
} )
.options( {
processCssUrls: false,
postCss,
} )
.sourceMaps( false, 'eval-source-map' );