vue.config.js 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. // const dev_baseURL = 'http://git.waywish.com:9100';
  2. const dev_baseURL = 'https://www.waywish.com';
  3. const isProduction = process.env.NODE_ENV === 'production'; //是否为生产环境
  4. const path = require("path");
  5. function resolve(dir) {
  6. return path.join(__dirname, dir);
  7. }
  8. module.exports = {
  9. publicPath: './',
  10. outputDir: '../src/main/resources/static/console',
  11. assetsDir: 'static',
  12. lintOnSave: false,
  13. productionSourceMap: false,
  14. // webpack配置
  15. // see https://github.com/vuejs/vue-cli/blob/dev/docs/webpack.md
  16. chainWebpack: config => {
  17. // 移除 prefetch 插件
  18. config.plugins.delete('prefetch')
  19. // 移除 preload 插件
  20. config.plugins.delete('preload');
  21. config.module.rule("svg").exclude.add(resolve("src/assets/icons")).end();
  22. config.module
  23. .rule("icons")
  24. .test(/\.svg$/)
  25. .include.add(resolve("src/assets/icons"))
  26. .end()
  27. .use("svg-sprite-loader")
  28. .loader("svg-sprite-loader")
  29. .options({
  30. symbolId: "icon-[name]",
  31. })
  32. // 生产环境配置
  33. if (isProduction) {
  34. // 压缩代码
  35. config.optimization.minimize(true);
  36. // 分割代码
  37. config.optimization.splitChunks({
  38. chunks: 'all'
  39. })
  40. }
  41. },
  42. configureWebpack: (config) => {
  43. // if (isProduction) {
  44. // config.optimization.minimizer[0].options.minimizer.options.compress = Object.assign(
  45. // config.optimization.minimizer[0].options.minimizer.options.compress, {
  46. // drop_console: true
  47. // }
  48. // );
  49. // }
  50. },
  51. devServer: {
  52. port: 8080, // 端口
  53. open: false, // 自动开启浏览器
  54. compress: false, // 开启压缩
  55. proxy: {
  56. '/v1': {
  57. target: dev_baseURL,
  58. changeOrigin: true,
  59. ws: true,
  60. pathRewrite: {
  61. '^/v1': ''
  62. }
  63. }
  64. }
  65. },
  66. // css相关配置
  67. css: {
  68. // css预设器配置项
  69. loaderOptions: {
  70. // pass options to sass-loader
  71. sass: {
  72. // 引入全局变量样式
  73. prependData: `
  74. @import "@/assets/scss/common.scss";
  75. `
  76. }
  77. },
  78. }
  79. }