vue.config.js 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207
  1. const path = require('path')
  2. const crypto = require('crypto')
  3. const TerserPlugin = require('terser-webpack-plugin')
  4. const isProduction = process.env.NODE_ENV === 'production'
  5. const enableProductionSourceMap = process.argv.includes('sourceMap')
  6. const needRewritePath = process.argv.includes('rewritePath')
  7. const { platform, arch } = process
  8. const sdkPathMap = {
  9. 'darwin:x64': './sdk/mac',
  10. 'darwin:arm64': './sdk/mac',
  11. 'win32:ia32': './sdk/win32',
  12. 'win32:x64': './sdk/win64',
  13. 'linux:x64': './sdk/linux'
  14. }
  15. const sdkPath = sdkPathMap[`${platform}:${arch}`]
  16. const origCreateHash = crypto.createHash
  17. crypto.createHash = (alg, opts) => {
  18. return origCreateHash(/^md\d$/.test(alg) ? 'sha256' : alg, opts)
  19. }
  20. function resolve (dir) {
  21. return path.join(__dirname, dir)
  22. }
  23. const date = new Date()
  24. const month = date.getMonth() < 9 ? '0' + (date.getMonth() + 1) : date.getMonth() + 1
  25. const day = date.getDate() < 10 ? '0' + date.getDate() : date.getDate()
  26. module.exports = {
  27. lintOnSave: true,
  28. crossorigin: 'anonymous',
  29. publicPath: '/',
  30. outputDir: 'dist',
  31. productionSourceMap: enableProductionSourceMap,
  32. parallel: false, // require('os').cpus().length > 1,
  33. devServer: {
  34. compress: false,
  35. host: '0.0.0.0',
  36. port: 8081,
  37. open: false,
  38. https: false
  39. },
  40. pluginOptions: {
  41. electronBuilder: {
  42. customFileProtocol: './',
  43. chainWebpackMainProcess: config => {
  44. config.module
  45. .rule('node')
  46. .test(/\.node$/)
  47. .use('native-ext-loader')
  48. .loader('native-ext-loader')
  49. .tap(options => {
  50. options = {
  51. rewritePath: isProduction && !needRewritePath ? null : resolve(sdkPath),
  52. emit: false
  53. }
  54. return options
  55. })
  56. .end()
  57. },
  58. builderOptions: {
  59. appId: 'video.sdk.zoom',
  60. productName: `zoom-video-sdk`,
  61. compression: 'maximum',
  62. artifactName: "${productName}_Setup_${version}.${copyright}.${ext}",
  63. copyright: `${month}${day}`,
  64. icon: `./src/assets/images/${platform}.ico`,
  65. asar: false,
  66. mac: {
  67. extraResources: [
  68. {
  69. from: './sdk/mac/ZoomVideoSDK/',
  70. to: '../Frameworks/'
  71. },
  72. {
  73. from: './sdk/mac/',
  74. to: './app/',
  75. filter: ["*.node"]
  76. }
  77. ],
  78. target: [
  79. {
  80. target: 'zip',
  81. arch: [arch]
  82. }
  83. ],
  84. extendInfo:{
  85. NSMicrophoneUsageDescription: "Please allow this program to access your microphone",
  86. NSCameraUsageDescription: "Please allow this program to access your camera"
  87. }
  88. },
  89. win: {
  90. extraResources: [
  91. {
  92. from: sdkPath,
  93. to: './app/'
  94. },
  95. {
  96. from: './config.json',
  97. to: '../'
  98. }
  99. ],
  100. target: [
  101. // configure generate a zip package that requires no installation
  102. // {
  103. // target: 'zip',
  104. // arch: ['ia32', 'x64']
  105. // },
  106. {
  107. target: 'nsis',
  108. arch: [arch]
  109. }
  110. ]
  111. },
  112. linux: {
  113. icon: './src/assets/images/linux.png',
  114. extraResources: [
  115. {
  116. from: sdkPath,
  117. to: './app/'
  118. },
  119. {
  120. from: './config.json',
  121. to: '../'
  122. }
  123. ],
  124. target: [
  125. {
  126. target: 'deb',
  127. arch: 'x64'
  128. }
  129. ]
  130. },
  131. nsis: {
  132. oneClick: false,
  133. allowElevation: true,
  134. allowToChangeInstallationDirectory: true,
  135. installerIcon: `./src/assets/images/${platform}.ico`,
  136. uninstallerIcon: `./src/assets/images/${platform}.ico`,
  137. installerHeaderIcon: `./src/assets/images/${platform}.ico`,
  138. createDesktopShortcut: true,
  139. createStartMenuShortcut: true,
  140. deleteAppDataOnUninstall: true,
  141. include: 'scripts/installer.nsh'
  142. }
  143. },
  144. externals: ['@electron/remote']
  145. }
  146. },
  147. css: {
  148. extract: isProduction ? {
  149. ignoreOrder: true,
  150. } : false,
  151. sourceMap: true,
  152. loaderOptions: {
  153. sass: {
  154. prependData: `
  155. @import "@/assets/style/index.scss";
  156. `
  157. }
  158. }
  159. },
  160. chainWebpack: config => {
  161. config.resolve.alias
  162. .set('@', resolve('src'))
  163. .set('@scss', resolve('src/assets/style'))
  164. .set('path', require.resolve('path-browserify'))
  165. if (isProduction) {
  166. config.plugins.delete('preload')
  167. config.plugins.delete('prefetch')
  168. config.optimization.minimize(true)
  169. config.optimization.splitChunks({
  170. chunks: 'all'
  171. })
  172. }
  173. },
  174. configureWebpack: config => {
  175. config.devtool = isProduction ? (enableProductionSourceMap ? 'inline-source-map' : undefined) : 'source-map'
  176. config.module.rules.push({
  177. test: /\.node$/,
  178. loader: 'native-ext-loader',
  179. options: {
  180. basePath: ['../app/'],
  181. rewritePath: isProduction && !needRewritePath ? (platform=='win32'?'./':null) : resolve(sdkPath),
  182. emit: false
  183. }
  184. })
  185. if (isProduction) {
  186. config.plugins.push(
  187. new TerserPlugin({
  188. cache: true,
  189. parallel: true,
  190. sourceMap: enableProductionSourceMap,
  191. terserOptions: {
  192. compress: {
  193. drop_console: true,
  194. drop_debugger: true
  195. }
  196. }
  197. })
  198. )
  199. }
  200. }
  201. }