-
Notifications
You must be signed in to change notification settings - Fork 0
/
webpack.mix.js
45 lines (31 loc) · 1.11 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
let glob = require('glob');
let mix = require('laravel-mix');
let WebpackShellPlugin = require('webpack-shell-plugin');
let configs = glob.sync('{./Modules/*/webpack.mix.js,./Themes/*/webpack.mix.js}');
if (process.env.module !== undefined) {
let module = process.env.module.charAt(0).toUpperCase() + process.env.module.slice(1);
configs = [`./Modules/${module}/webpack.mix.js`];
}
if (process.env.theme !== undefined) {
let theme = process.env.theme.charAt(0).toUpperCase() + process.env.theme.slice(1);
configs = [`./Themes/${theme}/webpack.mix.js`];
}
mix.setPublicPath('./')
.options({ processCssUrls: false });
let onBuildExit = [];
configs.forEach(config => {
require(config);
let module = config.match(/Modules\/(\w+?)\//);
let theme = config.match(/Themes\/(\w+?)\//);
if (module !== null) {
onBuildExit.push(`php artisan module:publish ${module[1]}`);
}
if (theme !== null) {
onBuildExit.push(`php artisan stylist:publish ${theme[1]}`);
}
});
mix.webpackConfig({
plugins: [
new WebpackShellPlugin({ onBuildExit }),
],
});