vue.config.js 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. var TerserPlugin = require("terser-webpack-plugin");
  2. var devProxy = {};
  3. try {
  4. devProxy = require("./dev-proxy");
  5. } catch (error) {}
  6. var proxy = process.env.NODE_ENV === "production" ? {} : devProxy;
  7. // 配置手册: https://cli.vuejs.org/zh/config/#vue-config-js
  8. // electron-bulder配置:https://www.electron.build/configuration/contents#extrafiles
  9. var config = {
  10. // publicPath: './',
  11. devServer: {
  12. port: 8066
  13. },
  14. pluginOptions: {
  15. electronBuilder: {
  16. nodeIntegration: true,
  17. externals: [
  18. "cropperjs",
  19. "crypto",
  20. "gm",
  21. "imagemagick",
  22. "deepmerge",
  23. "node-xlsx",
  24. "log4js"
  25. ],
  26. builderOptions: {
  27. extraFiles: [
  28. "extra/encrypt/**",
  29. "extra/font/**",
  30. "extra/imagemagick/**",
  31. "extra/zxing/**",
  32. "extra/zxingA/**",
  33. "extra/artControl/**",
  34. "extra/database/org.rdb",
  35. "config.sample.json",
  36. "sense_shield_installer_pub_2.2.0.46331.exe"
  37. ],
  38. win: {
  39. target: "portable",
  40. signAndEditExecutable: false
  41. }
  42. }
  43. }
  44. }
  45. };
  46. // compress配置手册:https://github.com/mishoo/UglifyJS2/tree/harmony#compress-options
  47. if (process.env.NODE_ENV === "production") {
  48. config.configureWebpack = {
  49. plugins: [],
  50. optimization: {
  51. minimizer: [
  52. new TerserPlugin({
  53. terserOptions: { compress: { drop_console: true } }
  54. })
  55. ]
  56. }
  57. };
  58. }
  59. if (proxy && Object.keys(proxy).length) {
  60. config.devServer.proxy = proxy;
  61. }
  62. // 解决iview自定义主题导入less报错
  63. config.css = {
  64. loaderOptions: {
  65. less: {
  66. javascriptEnabled: true
  67. }
  68. }
  69. };
  70. module.exports = config;