This repository has been archived by the owner on Sep 25, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwebpack.mix.js
84 lines (76 loc) · 1.8 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
const conf = {
proxy: 'wrskirbykit.test',
scripts: 'resources/js/index.js', // String or Array
styles: 'resources/css/index.css', // String or Array
// static: 'resources/static',
public: 'public/assets',
aliases: {
'@utils': 'resources/js/utils',
'@components': 'resources/js/components',
'@vendors': 'resources/js/vendors',
},
}
/**
* Global imports
* Mix (https://laravel-mix.com/docs/5.0/installation)
* Path (https://nodejs.org/api/path.html)
*/
const mix = require('laravel-mix')
const path = require('path')
/**
* Create js folders aliases and remove ../../../ hell
* https://webpack.js.org/configuration/resolve/
*/
if (conf.aliases) {
mix.alias(conf.aliases)
}
/**
* Build .js files
* https://laravel-mix.com/docs/5.0/mixjs
*/
if (conf.scripts) {
if (conf.scripts instanceof Array) {
conf.scripts.forEach((file) => {
mix.js(file, path.resolve(__dirname, 'js')).extract()
})
} else {
mix.js(path.resolve(__dirname, conf.scripts), 'js').extract()
}
}
/**
* Build .scss files
* https://laravel-mix.com/docs/5.0/css-preprocessors
*/
if (conf.styles) {
if (conf.styles instanceof Array) {
conf.styles.concat(conf.styles).forEach((file) => {
mix.css(file, path.resolve(__dirname, 'css'))
})
} else {
mix.css(path.resolve(__dirname, conf.styles), 'css')
}
}
if (conf.static) {
mix.copyDirectory(conf.static, path.join(conf.public, 'static'))
}
/**
* Browsersync
* Mix (https://laravel-mix.com/docs/5.0/browsersync)
* BrowserSync (https://browsersync.io/docs/options)
*/
mix.browserSync({
proxy: conf.proxy || false,
ghostMode: false,
notify: false,
watch: true
})
/**
* Misc
*/
mix
.disableNotifications()
.setPublicPath(conf.public || '')
.options({ processCssUrls: false })
if (mix.inProduction()) {
mix.version()
}