tauri-config.js 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. const appPaths = require('./app-paths')
  2. const merge = require('webpack-merge')
  3. const error = require('../helpers/logger')('ERROR:', 'red')
  4. const { existsSync } = require('fs-extra')
  5. module.exports = cfg => {
  6. const pkgPath = appPaths.resolve.app('package.json')
  7. const tauriConfPath = appPaths.resolve.app('tauri.conf.js')
  8. if (!existsSync(pkgPath)) {
  9. error('Could not find a package.json in your app\'s directory.')
  10. process.exit(1)
  11. }
  12. if (!existsSync(tauriConfPath)) {
  13. error('Could not find a tauri config (tauri.conf.js) in your app\'s directory.')
  14. process.exit(1)
  15. }
  16. const tauriConf = require(tauriConfPath)(cfg.ctx)
  17. const pkg = require(pkgPath)
  18. const config = merge({
  19. build: {},
  20. ctx: {},
  21. tauri: {
  22. embeddedServer: {
  23. active: true
  24. },
  25. bundle: {
  26. active: true
  27. },
  28. whitelist: {
  29. all: false
  30. },
  31. window: {
  32. title: pkg.productName
  33. },
  34. security: {
  35. csp: 'default-src data: filesystem: ws: http: https: \'unsafe-eval\' \'unsafe-inline\''
  36. },
  37. edge: {
  38. active: true
  39. }
  40. }
  41. }, tauriConf, cfg)
  42. process.env.TAURI_DIST_DIR = appPaths.resolve.app(config.build.distDir)
  43. process.env.TAURI_DIR = appPaths.tauriDir
  44. return config
  45. }