vue.config.js 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. // var webpack = require("webpack");
  2. var TerserPlugin = require("terser-webpack-plugin");
  3. var CompressionPlugin = require("compression-webpack-plugin");
  4. var devProxy = {
  5. "/api/": {
  6. target: process.env.VUE_APP_DEV_PROXY,
  7. changeOrigin: true
  8. }
  9. };
  10. // 配置手册: https://cli.vuejs.org/zh/config/#vue-config-js
  11. var config = {
  12. // publicPath: './',
  13. productionSourceMap: false,
  14. devServer: {
  15. port: 8076,
  16. proxy: devProxy
  17. },
  18. transpileDependencies: ["vue-echarts", "resize-detector"],
  19. chainWebpack: config => {
  20. // webpack-chain配置手册:github.com/neutrinojs/webpack-chain#getting-started
  21. // config.plugin("provide").use(webpack.ProvidePlugin, [
  22. // {
  23. // "window.Quill": "quill/dist/quill.js",
  24. // Quill: "quill/dist/quill.js"
  25. // }
  26. // ]);
  27. }
  28. };
  29. // compress配置手册:https://github.com/mishoo/UglifyJS2/tree/harmony#compress-options
  30. if (process.env.NODE_ENV === "production") {
  31. config.configureWebpack = {
  32. plugins: [
  33. // gzip
  34. new CompressionPlugin({
  35. filename: "[path].gz[query]",
  36. algorithm: "gzip",
  37. test: new RegExp("\\.(js|css)$"),
  38. threshold: 10240,
  39. minRatio: 0.8
  40. })
  41. ],
  42. optimization: {
  43. minimizer: [
  44. new TerserPlugin({
  45. terserOptions: { compress: { drop_console: true } }
  46. })
  47. ]
  48. }
  49. };
  50. }
  51. // 解决iview自定义主题导入less报错
  52. config.css = {
  53. loaderOptions: {
  54. less: {
  55. javascriptEnabled: true
  56. }
  57. }
  58. };
  59. module.exports = config;