vue.config.js 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. const path = require('path')
  2. function resolve(dir) {
  3. return path.join(__dirname, dir)
  4. }
  5. module.exports = {
  6. // https://github.com/vuejs/vue-docs-zh-cn/blob/master/vue-cli-plugin-eslint/README.md
  7. lintOnSave: process.env.NODE_ENV !== 'production',
  8. // 为项目文件夹配置别名
  9. configureWebpack: {
  10. resolve: {
  11. alias: {
  12. assets: '@/assets',
  13. components: '@/components',
  14. network: '@/network',
  15. views: '@/views'
  16. }
  17. }
  18. },
  19. devServer: {
  20. port: 8000, // 修改端口
  21. disableHostCheck: true,
  22. overlay: {
  23. warnings: false,
  24. errors: true
  25. }
  26. // 跨域代理配置
  27. /* proxy: {
  28. '/api': {
  29. target: 'http://loclahost:8080', // 这里是接口地址
  30. ws: true, // 是否代理websockets
  31. changeOrigin: true, // 设置同源 默认false,是否需要改变原始主机头为目标URL
  32. pathRewrite: {
  33. '^/api': ''
  34. }
  35. }
  36. }*/
  37. },
  38. // 添加chainWebpack支持swf
  39. chainWebpack: config => {
  40. config.module
  41. .rule('swf')
  42. .test(/\.swf$/)
  43. .use('url-loader')
  44. .loader('url-loader')
  45. .options({
  46. limit: 10000
  47. })
  48. },
  49. pluginOptions: {
  50. 'style-resources-loader': {
  51. preProcessor: 'scss',
  52. patterns: [
  53. //全局加载 less 变量
  54. path.resolve(__dirname, './src/assets/css/variable.scss'),
  55. ],
  56. },
  57. },
  58. publicPath: '/'
  59. }