-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwebpack.mix.js
59 lines (48 loc) · 1.69 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
const fs = require('fs');
const mix = require('laravel-mix');
const path = require('path');
// Create some aliases
mix.alias({
'@base': path.join(__dirname, 'resources/scss'),
'@blockDir': path.join(__dirname, 'blocks'),
'@shortcodesDir': path.join(__dirname, 'shortcodes')
});
// Set the public path
mix.setPublicPath('.');
// Don't perform any CSS URL rewriting
mix.options({
processCssUrls: false,
});
// Compile JS
mix.js('resources/js/app.js', 'assets/js');
mix.js('resources/js/editor.js', 'assets/js');
// Compile SCSS
mix.sass('resources/scss/critical.scss', 'assets/css');
mix.sass('resources/scss/style.scss', 'assets/css');
mix.sass('resources/scss/editor.scss', 'assets/css');
// Compile block assets
fs.readdirSync("blocks").forEach(dirName => {
// JS
if (fs.existsSync(`blocks/${dirName}/resources/js/${dirName}.js`)) {
mix.js(`blocks/${dirName}/resources/js/${dirName}.js`, 'assets/js/blocks');
}
// SCSS
if (fs.existsSync(`blocks/${dirName}/resources/scss/${dirName}.scss`)) {
mix.sass(`blocks/${dirName}/resources/scss/${dirName}.scss`, 'assets/css/blocks');
}
});
// Compile shortcode assets
fs.readdirSync("shortcodes").forEach(dirName => {
// JS
if (fs.existsSync(`shortcodes/${dirName}/resources/js/${dirName}.js`)) {
mix.js(`shortcodes/${dirName}/resources/js/${dirName}.js`, 'assets/js/shortcodes');
}
// SCSS
if (fs.existsSync(`shortcodes/${dirName}/resources/scss/${dirName}.scss`)) {
mix.sass(`shortcodes/${dirName}/resources/scss/${dirName}.scss`, 'assets/css/shortcodes');
}
});
// Enable versioning
mix.version();
// Enable source mapping
mix.sourceMaps(false, 'source-map');