-
Notifications
You must be signed in to change notification settings - Fork 31
Expand file tree
/
Copy pathwebpack.mix.js
More file actions
44 lines (29 loc) · 869 Bytes
/
webpack.mix.js
File metadata and controls
44 lines (29 loc) · 869 Bytes
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
// webpack.mix.js
const mix = require('laravel-mix');
const glob = require('glob');
// Define the blocks directory
const blocksDir = 'blocks';
// Config
mix.webpackConfig({
stats: {
children: true
}
});
// CSS
mix.
sass('assets/styles/style.scss', 'style.css')
.options({
processCssUrls: false
});
// JS
// Scan block subdirectories for JS files to include
let jsFiles = glob.sync(`${blocksDir}/**/*.js`).filter(file => !file.endsWith('.min.js'));
// Add main `scripts.js` to the files to be compiled
jsFiles.unshift('assets/scripts/scripts.js');
// Compile the files into a single output file
mix.js(jsFiles, 'js/scripts.min.js');
// Compile block stylesheets to individual CSS files
glob.sync(`${blocksDir}/**/*.scss`).forEach(file => {
let output = file.replace('.scss', '.css');
mix.sass(file, output);
});