vue.config.js 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. const path = require('path')
  2. const minify = process.env.NODE_ENV === 'development' ? false : {
  3. collapseWhitespace: true,
  4. removeComments: true,
  5. removeRedundantAttributes: true,
  6. removeScriptTypeAttributes: true,
  7. removeStyleLinkTypeAttributes: true,
  8. useShortDoctype: true,
  9. minifyCSS: true,
  10. minifyJS: true
  11. }
  12. function resolve(dir) {
  13. return path.join(__dirname, dir)
  14. }
  15. module.exports = {
  16. publicPath: '/',
  17. lintOnSave: true,
  18. runtimeCompiler: true,
  19. pages: {
  20. index: {
  21. entry: 'src/main.js',
  22. template: 'public/index.html',
  23. filename: 'index.html',
  24. chunks: ['chunk-vendors', 'chunk-common', 'index'],
  25. minify
  26. },
  27. preview: {
  28. entry: 'src/views/preview/main.js',
  29. template: 'public/preview.html',
  30. filename: 'preview.html',
  31. chunks: ['chunk-vendors', 'chunk-common', 'preview'],
  32. minify
  33. }
  34. },
  35. pluginOptions: {
  36. 'style-resources-loader': {
  37. preProcessor: 'less',
  38. patterns: [
  39. path.resolve(__dirname, './src/styles/variables.less')
  40. ]
  41. }
  42. },
  43. devServer: {
  44. proxy: {
  45. '/api': {
  46. target: 'https://wy-test.huiguanjia.cn/9ad134a361f8d778/', // 对应自己的接口
  47. changeOrigin: true,
  48. ws: false,
  49. pathRewrite: {
  50. '^/api': ''
  51. }
  52. }
  53. },
  54. overlay: {
  55. // 错误信息显示到浏览器上
  56. warnings: false,
  57. errors: true
  58. }
  59. },
  60. css: {
  61. // 开启样式追溯
  62. sourceMap: true
  63. },
  64. productionSourceMap: false,
  65. chainWebpack(config) {
  66. config.resolve.alias.set('@', resolve('src'))
  67. // set svg-sprite-loader
  68. config.module
  69. .rule('svg')
  70. .exclude.add(resolve('src/icons'))
  71. .end()
  72. config.module
  73. .rule('icons')
  74. .test(/\.svg$/)
  75. .include.add(resolve('src/icons'))
  76. .end()
  77. .use('svg-sprite-loader')
  78. .loader('svg-sprite-loader')
  79. .options({
  80. symbolId: 'icon-[name]'
  81. })
  82. .end()
  83. }
  84. }