vue.config.js 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. var webpack = require("webpack");
  2. var TerserPlugin = require("terser-webpack-plugin");
  3. var devProxy = {
  4. "/api/": {
  5. target: process.env.VUE_APP_DEV_PROXY,
  6. changeOrigin: true
  7. }
  8. };
  9. // 配置手册: https://cli.vuejs.org/zh/config/#vue-config-js
  10. var config = {
  11. // publicPath: './',
  12. devServer: {
  13. port: 8056,
  14. proxy: devProxy
  15. },
  16. chainWebpack: config => {
  17. // webpack-chain配置手册:github.com/neutrinojs/webpack-chain#getting-started
  18. config.plugin("provide").use(webpack.ProvidePlugin, [
  19. {
  20. "window.Quill": "quill/dist/quill.js",
  21. Quill: "quill/dist/quill.js"
  22. }
  23. ]);
  24. // 限制base64图片的大小在20kb以下
  25. config.module
  26. .rule("images")
  27. .use("url-loader")
  28. .loader("url-loader")
  29. .tap(options =>
  30. Object.assign(options, { limit: 20480, esModule: false })
  31. );
  32. }
  33. };
  34. // compress配置手册:https://github.com/mishoo/UglifyJS2/tree/harmony#compress-options
  35. if (process.env.NODE_ENV === "production") {
  36. config.configureWebpack = {
  37. optimization: {
  38. minimizer: [
  39. new TerserPlugin({
  40. terserOptions: { compress: { drop_console: true } }
  41. })
  42. ]
  43. }
  44. };
  45. }
  46. module.exports = config;