vue.config.js 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  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. plugins: [
  45. new Happypack({
  46. loaders: ['babel-loader', 'vue-loader'],
  47. cache: true,
  48. threads: 10 // 线程数取决于你电脑性能的好坏,好的电脑建议开更多线程
  49. })
  50. ]
  51. },
  52. devServer: {
  53. port: 8080, // 端口
  54. open: false, // 自动开启浏览器
  55. compress: false, // 开启压缩
  56. proxy: {
  57. '/v1': {
  58. target: dev_baseURL,
  59. changeOrigin: true,
  60. ws: true,
  61. pathRewrite: {
  62. '^/v1': ''
  63. }
  64. }
  65. }
  66. },
  67. // css相关配置
  68. css: {
  69. // css预设器配置项
  70. loaderOptions: {
  71. // pass options to sass-loader
  72. sass: {
  73. // 引入全局变量样式
  74. prependData: `
  75. @import "@/assets/scss/common.scss";
  76. `
  77. }
  78. },
  79. }
  80. }