KawAnime/vue.config.js

139 lines
3.7 KiB
JavaScript
Raw Normal View History

const fs = require('fs')
const path = require('path')
/**
* Taken from https://gist.github.com/kethinov/6658166#gistcomment-2389484
*
* Find all files inside a dir, recursively.
* @function getAllFiles
* @param {string} dir Dir path string.
* @return {string[]} Array with all file names that are inside the directory.
*/
const getAllFiles = (dir) =>
fs.readdirSync(dir).reduce((files, file) => {
const name = path.join(dir, file)
const isDirectory = fs.statSync(name).isDirectory()
return isDirectory ? [...files, ...getAllFiles(name)] : [...files, name]
}, [])
2019-07-20 10:58:25 +00:00
const VERSION = JSON.parse(fs.readFileSync(path.resolve(__dirname, 'package.json'))).version
2019-07-13 14:51:59 +00:00
const VENDOR_PATH = path.join(__dirname, 'src', 'vendor')
const BIDNINGS_PATH = path.join(__dirname, 'bindings')
2020-01-30 01:27:49 +00:00
const PUBLIC_PATH = path.join(__dirname, 'public')
2019-07-13 14:51:59 +00:00
2019-07-20 10:58:25 +00:00
process.env.VUE_APP_KAWANIME_VERSION = VERSION
module.exports = {
configureWebpack: {
2019-07-13 14:51:59 +00:00
devtool: 'source-map',
resolve: {
alias: {
'@': path.join(__dirname, 'src', 'renderer'),
'vendor': VENDOR_PATH
}
},
entry: {
app: './src/renderer/main.js'
}
},
pluginOptions: {
electronBuilder: {
externals: ['kawabinds'],
builderOptions: {
2019-06-14 15:58:34 +00:00
appId: 'KawAnime',
productName: 'KawAnime',
dmg: {
contents: [
{
x: 150,
y: 90
},
{
x: 150,
y: 275,
type: 'link',
path: '/Applications'
}
]
},
nsis: {
oneClick: false,
allowToChangeInstallationDirectory: true
},
fileAssociations: [
{
ext: 'torrent',
name: 'Torrent files'
}
2019-06-12 20:20:25 +00:00
],
protocols: [{
name: 'kawanime-app-external',
schemes: [
'kawanime-app'
]
2019-11-08 14:20:40 +00:00
}],
linux: {
category: 'Network',
2020-01-16 00:48:03 +00:00
extraResources: [
{
from: './bindings/build/Release',
to: '.',
filter: ['*.so']
2020-01-16 00:48:03 +00:00
},
{
from: './public/mpv',
to: 'mpv',
filter: ['*.so', '*.node']
}
]
},
2019-11-08 14:20:40 +00:00
win: {
2020-01-16 00:48:03 +00:00
extraResources: [
2019-11-08 14:20:40 +00:00
{
from: '.\\bindings\\build\\Release',
to: '.',
filter: ['*.dll']
2020-01-16 00:48:03 +00:00
},
{
from: '.\\public\\mpv',
to: 'mpv',
filter: ['*.dll', '*.node']
}
2019-11-08 14:20:40 +00:00
]
}
},
chainWebpackMainProcess: (config) => {
// Chain webpack config for electron main process only
config
.module
.rule('node')
.test(/\.node$/)
.use('native-ext-loader')
.loader('native-ext-loader')
.end()
2019-07-13 14:51:59 +00:00
config
.resolve
.alias
.set('vendor', VENDOR_PATH)
.set('kawabinds', BIDNINGS_PATH)
2020-01-30 01:27:49 +00:00
.set('public', PUBLIC_PATH)
},
chainWebpackRendererProcess: (config) => {
// Chain webpack config for electron renderer process only
// The following example will set IS_ELECTRON to true in your app
config.plugin('define').tap((args) => {
args[0]['IS_ELECTRON'] = true
return args
})
},
// Use this to change the entrypoint of your app's main process
2019-07-13 14:51:59 +00:00
mainProcessFile: 'src/main/index.js',
// Provide an array of files that, when changed, will recompile the main process and restart Electron
// Your main process file will be added by default
2019-07-13 14:51:59 +00:00
mainProcessWatch: getAllFiles('src/main'),
outputDir: 'dist'
}
}
}