vue.config.js 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. const path = require('path')
  2. var webpack = require('webpack')
  3. const defaultSettings = require('./src/settings.js')
  4. const name = defaultSettings.title || 'SASS' //标题
  5. function resolve(dir) {
  6. return path.join(__dirname, dir)
  7. }
  8. module.exports = {
  9. //路径前缀
  10. publicPath: '/',
  11. lintOnSave: true,
  12. productionSourceMap: false,
  13. chainWebpack: (config) => {
  14. config.plugin('provide').use(webpack.ProvidePlugin, [
  15. {
  16. 'window.Quill': 'quill/dist/quill.js',
  17. Quill: 'quill/dist/quill.js',
  18. },
  19. ])
  20. //忽略的打包文件
  21. config.externals({
  22. vue: 'Vue',
  23. 'vue-router': 'VueRouter',
  24. vuex: 'Vuex',
  25. axios: 'axios',
  26. })
  27. const entry = config.entry('app')
  28. entry.add('babel-polyfill').end()
  29. entry.add('classlist-polyfill').end()
  30. entry.add('@/mock').end()
  31. config.resolve.alias
  32. .set('@', resolve('packages'))
  33. .set('@utils', resolve('packages/utils'))
  34. .set('@mixins', resolve('packages/mixins'))
  35. .set('@', resolve('src'))
  36. // set svg-sprite-loader
  37. config.module.rules.delete('svg') // 重点:删除默认配置中处理svg
  38. config.module
  39. .rule('svg-sprite-loader')
  40. .test(/\.svg$/)
  41. .include.add(resolve('src/icons')) // 处理svg目录
  42. .end()
  43. .use('svg-sprite-loader')
  44. .loader('svg-sprite-loader')
  45. .options({
  46. symbolId: 'icon-[name]',
  47. })
  48. },
  49. css: {
  50. extract: {
  51. ignoreOrder: true,
  52. },
  53. },
  54. //开发模式反向代理配置,生产模式请使用Nginx部署并配置反向代理
  55. devServer: {
  56. port: 1666,
  57. proxy: {
  58. [process.env.VUE_APP_BASE_API]: {
  59. //本地服务接口地址
  60. target: 'http://www.printmat.cn:8866',
  61. // target: 'http://116.205.162.119:8866',
  62. // target: 'http://192.168.1.164:8866',
  63. changeOrigin: true,
  64. pathRewrite: {
  65. [`^${process.env.VUE_APP_BASE_API}`]: '/',
  66. },
  67. },
  68. },
  69. },
  70. configureWebpack: {
  71. name: name,
  72. resolve: {
  73. alias: {
  74. '@': resolve('src'),
  75. },
  76. },
  77. // 解决xlxs-style报错问题
  78. externals: {
  79. './cptable': 'var cptable',
  80. },
  81. // devtool: 'source-map', // 配置本地调试
  82. },
  83. }