-
Notifications
You must be signed in to change notification settings - Fork 0
/
webpack.mix.js
69 lines (55 loc) · 2.03 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
let mix = require('laravel-mix');
// read theme from .env
require('dotenv').config();
var theme = process.env.MIX_THEME || 'grey';
/*
|--------------------------------------------------------------------------
| Mix Asset Management
|--------------------------------------------------------------------------
|
| 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.
|
*/
// using scripts instead of js to avoid webpack bloating plain js - must specify full path to output file
mix.scripts('resources/assets/js/app.js', 'public_html/js/app.js');
mix.scripts('resources/assets/js/lazyload.js', 'public_html/js/lazyload.js');
mix.copy('resources/assets/js/intersectionobserver.min.js', 'public_html/js/intersectionobserver.min.js');
mix.scripts('resources/assets/js/sw.js', 'public_html/sw.js');
// set the root here for sass, scripts don't follow it
mix.setPublicPath('./public_html/');
// stop mix from messing with the images because we're doing that ourselves now
mix.options({
processCssUrls: false,
imgLoaderOptions: {
enabled: false,
}
});
// standard scss compile
mix.sass('resources/assets/sass/' + theme + '/critical.scss', 'css').options({
autoprefixer: false
});
mix.sass('resources/assets/sass/' + theme + '/app.scss', 'css').options({
autoprefixer: false
});
// auto cache bust
mix.version();
// allow themes to have an optional image directory
let fs = require('fs');
fs.stat('resources/assets/img/' + theme, function(err) {
if (err === null) {
mix.copyDirectory('resources/assets/img/' + theme, 'public_html/img');
} else {
// clean up theme changes
const del = require('del');
del('public_html/img');
}
});
mix.copyDirectory('resources/assets/webapp/' + theme + '/', 'public_html/');
// sourcemaps only happen if minified i.e. prod
// mix.sourceMaps();
// disable notifications if building on server
// if (mix.inProduction()) {
// mix.disableNotifications();
// }