56 lines
1.3 KiB
JavaScript
Vendored
56 lines
1.3 KiB
JavaScript
Vendored
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 output = {
|
|
chunkFilename: function ({chunk}) {
|
|
return `js/build/${mixBuildName(chunk.id)}.js`
|
|
}
|
|
};
|
|
if (!['--watch', '--hot'].includes(argv[3])) {
|
|
output.publicPath = './';
|
|
}
|
|
|
|
let platform = "web";
|
|
let publicPath = 'public'
|
|
if (argv[4] === '--electron') {
|
|
platform = "electron"
|
|
publicPath = 'electron/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(webpack => {
|
|
return {
|
|
output,
|
|
plugins: [
|
|
new webpack.DefinePlugin({
|
|
'__PLATFORM': platform
|
|
})
|
|
]
|
|
}
|
|
})
|
|
.options({
|
|
processCssUrls: false,
|
|
hmrOptions: {
|
|
host: ipv4 || 'localhost',
|
|
port: '22222'
|
|
},
|
|
})
|
|
.vue({
|
|
version: 2,
|
|
});
|