tauri-config.js 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  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. distDir: './dist'
  21. },
  22. ctx: {},
  23. tauri: {
  24. embeddedServer: {
  25. active: true
  26. },
  27. bundle: {
  28. active: true
  29. },
  30. whitelist: {
  31. all: false
  32. },
  33. window: {
  34. title: pkg.productName
  35. },
  36. security: {
  37. csp: 'default-src data: filesystem: ws: http: https: \'unsafe-eval\' \'unsafe-inline\''
  38. },
  39. automaticStart: {
  40. active: false,
  41. devArgs: [],
  42. buildArgs: []
  43. },
  44. edge: {
  45. active: true
  46. }
  47. }
  48. }, tauriConf, cfg)
  49. process.env.TAURI_DIST_DIR = appPaths.resolve.app(config.build.distDir)
  50. process.env.TAURI_CONFIG_DIR = appPaths.tauriDir
  51. return config
  52. }