vue.config.js 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. const dev_baseURL = 'http://git.waywish.com:9100';
  2. // const dev_baseURL = 'https://www.workark.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',
  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. // 生产环境配置
  22. if (isProduction) {
  23. // 压缩代码
  24. config.optimization.minimize(true);
  25. // 分割代码
  26. config.optimization.splitChunks({
  27. chunks: 'all'
  28. })
  29. }
  30. },
  31. configureWebpack: (config) => {
  32. // if (isProduction) {
  33. // config.optimization.minimizer[0].options.minimizer.options.compress = Object.assign(
  34. // config.optimization.minimizer[0].options.minimizer.options.compress, {
  35. // drop_console: true
  36. // }
  37. // );
  38. // }
  39. },
  40. devServer: {
  41. port: 8080, // 端口
  42. open: false, // 自动开启浏览器
  43. compress: false, // 开启压缩
  44. proxy: {
  45. '/v1': {
  46. target: dev_baseURL,
  47. changeOrigin: true,
  48. ws: true,
  49. pathRewrite: {
  50. '^/v1': ''
  51. }
  52. }
  53. }
  54. },
  55. // css相关配置
  56. css: {
  57. // css预设器配置项
  58. loaderOptions: {
  59. // pass options to sass-loader
  60. sass: {
  61. // 引入全局变量样式
  62. prependData: `
  63. @import "@/assets/scss/common.scss";
  64. `
  65. }
  66. },
  67. }
  68. }