forked from kuaifan/dootask
-
Notifications
You must be signed in to change notification settings - Fork 0
/
webpack.mix.js
46 lines (43 loc) · 1.23 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
const mix = require('laravel-mix');
const ipv4 = require('internal-ip').v4.sync();
const argv = process.argv;
let mixBuildName = function (str) {
if (typeof str !== "string") {
return str;
}
if (/resources_assets_js_pages_(.*?)_vue/.test(str)) {
str = /resources_assets_js_pages_(.*?)_vue/.exec(str)[1];
}
return str.replace(/_/g, '/');
}
let isHot = argv.includes('--hot');
let isElectron = argv.includes('--electron');
let publicPath = (!isHot && isElectron) ? 'electron/public' : 'public';
mix
.copy('resources/assets/statics/public', publicPath)
.js('resources/assets/js/app.js', 'js')
.sass('resources/assets/sass/app.scss', 'css')
.setPublicPath(publicPath)
.webpackConfig(() => {
let config = {
output: {
chunkFilename: ({chunk}) => {
return `js/build/${mixBuildName(chunk.id)}.js`
}
}
};
if (isElectron && !isHot) {
config.output.publicPath = './'
}
return config
})
.options({
processCssUrls: false,
hmrOptions: {
host: ipv4 || 'localhost',
port: '22222'
},
})
.vue({
version: 2,
});