vue.config.js 1.5 KB

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