vue.config.js 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. const {
  2. defineConfig
  3. } = require('@vue/cli-service');
  4. const dev_baseURL = 'https://www.waywish.com';
  5. const isProduction = process.env.NODE_ENV === 'production'; //是否为生产环境
  6. const path = require("path");
  7. const resolve = (dir) => {
  8. return path.join(__dirname, dir);
  9. }
  10. module.exports = defineConfig({
  11. publicPath: './',
  12. outputDir: '../src/main/resources/static/workark',
  13. assetsDir: 'static',
  14. lintOnSave: false,
  15. productionSourceMap: false,
  16. // webpack配置
  17. // see https://github.com/vuejs/vue-cli/blob/dev/docs/webpack.md
  18. chainWebpack: config => {
  19. // 移除 prefetch 插件
  20. config.plugins.delete('prefetch')
  21. // 移除 preload 插件
  22. config.plugins.delete('preload');
  23. // 生产环境配置
  24. if (isProduction) {
  25. // 压缩代码
  26. config.optimization.minimize(true);
  27. // 分割代码
  28. config.optimization.splitChunks({
  29. chunks: 'all'
  30. })
  31. }
  32. },
  33. configureWebpack: {
  34. devtool: process.env.NODE_ENV === 'development' ? 'eval' : false,
  35. plugins: []
  36. },
  37. devServer: {
  38. port: 8080, // 端口
  39. open: false, // 自动开启浏览器
  40. compress: false, // 开启压缩
  41. hot: true, // 模块热替换
  42. client: {
  43. overlay: { // 当出现编译错误或警告时,在浏览器中显示全屏覆盖。
  44. warnings: true,
  45. errors: true
  46. },
  47. progress: true, // 在浏览器中以百分比形式打印编译进度。
  48. },
  49. proxy: {
  50. '/v1': {
  51. target: dev_baseURL,
  52. changeOrigin: true,
  53. ws: true,
  54. pathRewrite: {
  55. '^/v1': ''
  56. }
  57. }
  58. }
  59. },
  60. // css相关配置
  61. css: {
  62. // css预设器配置项
  63. loaderOptions: {
  64. // pass options to sass-loader
  65. sass: {
  66. // 引入全局变量样式
  67. prependData: `
  68. @import "@/assets/css/element-variables.scss";
  69. `
  70. }
  71. },
  72. }
  73. })