vue.config.js 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  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. const Happypack = require('happypack');
  6. function resolve(dir) {
  7. return path.join(__dirname, dir);
  8. }
  9. module.exports = {
  10. publicPath: './',
  11. outputDir: '../src/main/resources/static/console',
  12. assetsDir: 'static',
  13. lintOnSave: false,
  14. productionSourceMap: false,
  15. // webpack配置
  16. // see https://github.com/vuejs/vue-cli/blob/dev/docs/webpack.md
  17. chainWebpack: config => {
  18. // 移除 prefetch 插件
  19. config.plugins.delete('prefetch')
  20. // 移除 preload 插件
  21. config.plugins.delete('preload');
  22. config.module.rule("svg").exclude.add(resolve("src/assets/icons")).end();
  23. config.module
  24. .rule("icons")
  25. .test(/\.svg$/)
  26. .include.add(resolve("src/assets/icons"))
  27. .end()
  28. .use("svg-sprite-loader")
  29. .loader("svg-sprite-loader")
  30. .options({
  31. symbolId: "icon-[name]",
  32. })
  33. // 生产环境配置
  34. if (isProduction) {
  35. // 压缩代码
  36. config.optimization.minimize(true);
  37. // 分割代码
  38. config.optimization.splitChunks({
  39. chunks: 'all'
  40. })
  41. }
  42. },
  43. configureWebpack: {
  44. devtool: process.env.NODE_ENV === 'development' ? 'eval' : false,
  45. plugins: [
  46. new Happypack({
  47. loaders: ['babel-loader', 'vue-loader'],
  48. cache: true,
  49. threads: 10 // 线程数取决于你电脑性能的好坏,好的电脑建议开更多线程
  50. })
  51. ]
  52. },
  53. devServer: {
  54. port: 8080, // 端口
  55. open: false, // 自动开启浏览器
  56. compress: false, // 开启压缩
  57. hot: true, // 模块热替换
  58. client: {
  59. overlay: { // 当出现编译错误或警告时,在浏览器中显示全屏覆盖。
  60. warnings: true,
  61. errors: true
  62. },
  63. progress: true, // 在浏览器中以百分比形式打印编译进度。
  64. },
  65. proxy: {
  66. '/v1': {
  67. target: dev_baseURL,
  68. changeOrigin: true,
  69. ws: true,
  70. pathRewrite: {
  71. '^/v1': ''
  72. }
  73. }
  74. }
  75. },
  76. // css相关配置
  77. css: {
  78. // css预设器配置项
  79. loaderOptions: {
  80. // pass options to sass-loader
  81. sass: {
  82. // 引入全局变量样式
  83. prependData: `
  84. @import "@/assets/scss/common.scss";
  85. `
  86. }
  87. },
  88. }
  89. }