vue.config.js 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  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. builderOptions: {
  17. extraFiles: [
  18. "extra/imagemagick/**",
  19. "extra/zxing/**",
  20. "extra/database/org.rdb",
  21. "config.sample.json"
  22. ]
  23. }
  24. }
  25. }
  26. };
  27. // compress配置手册:https://github.com/mishoo/UglifyJS2/tree/harmony#compress-options
  28. if (process.env.NODE_ENV === "production") {
  29. config.configureWebpack = {
  30. plugins: [],
  31. optimization: {
  32. minimizer: [
  33. new TerserPlugin({
  34. terserOptions: { compress: { drop_console: true } }
  35. })
  36. ]
  37. }
  38. };
  39. }
  40. if (proxy && Object.keys(proxy).length) {
  41. config.devServer.proxy = proxy;
  42. }
  43. // 解决iview自定义主题导入less报错
  44. config.css = {
  45. loaderOptions: {
  46. less: {
  47. javascriptEnabled: true
  48. }
  49. }
  50. };
  51. module.exports = config;