forked from knowler/sage-gutenberg-acf-tailwind-example
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathwebpack.mix.js
93 lines (79 loc) · 1.98 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
const mix = require('laravel-mix')
/**
* Plugins
*/
require('laravel-mix-purgecss')
/**
* Helpers
*/
// Public path helper
const publicPath = path => `${mix.config.publicPath}/${path}`
// Source path helper
const src = path => `resources/assets/${path}`
/*
|--------------------------------------------------------------------------
| Mix Asset Management
|--------------------------------------------------------------------------
|
| Mix provides a clean, fluent API for defining some Webpack build steps
| for your Sage application. By default, we are compiling the Sass file
| for your application, as well as bundling up your JS files.
|
*/
mix
.setPublicPath('./dist')
.setResourceRoot(`/app/themes/sage/${mix.config.publicPath}/`)
.webpackConfig({
output: { publicPath: mix.config.resourceRoot },
})
.browserSync('sage-block-builder-example.test')
/**
* Styles
*/
// Common PostCSS plugins
const postCssPlugins = [
require('postcss-import')(),
require('tailwindcss')(),
require('postcss-preset-env')({ stage: 0 }),
]
// CSS configuration
mix
.postCss(src`styles/app.css`, 'styles', postCssPlugins)
.postCss(src`styles/editor.css`, 'styles', [
...postCssPlugins,
require('postcss-wrap')({
selector: '.acf-block-preview',
skip: /acf-block-preview/,
}),
])
.purgeCss({
content: [
'./resources/assets/**/*.js',
'./resources/views/**/*.php',
'./resources/fields/controls/**/*.php',
],
defaultExtractor: content => content.match(/[A-Za-z0-9-_:/]+/g || []),
whitelistPatterns: [
/acf-block-preview/,
],
})
.options({ processCssUrls: false })
/**
* Scripts
*/
mix
.js(src`scripts/app.js`, 'scripts')
.extract()
/**
* Assets
*/
mix
.copyDirectory(src`images`, publicPath`images`)
.copyDirectory(src`fonts`, publicPath`fonts`)
/**
* Environment specifics
*/
// Source maps when not in production.
mix.sourceMaps(false, 'source-map')
// Hash and version files in production.
mix.version()