vue.config.js 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. // var webpack = require('webpack');
  2. //vue2
  3. const path = require('path')
  4. function resolve(dir) {
  5. return path.join(__dirname, dir)
  6. }
  7. function publicPath(){
  8. if (process.env.NODE_ENV == 'production') {
  9. return "././";
  10. } else {
  11. return "/";
  12. }
  13. }
  14. // vue.config.js
  15. module.exports = {
  16. // publicPath:"././",
  17. publicPath: publicPath(),
  18. // 国际化配置 使用其它语言,默认情况下中文语言包依旧是被引入的
  19. configureWebpack: {
  20. // plugins: [
  21. // new webpack.NormalModuleReplacementPlugin(/element-ui[\/\\]lib[\/\\]locale[\/\\]lang[\/\\]zh-CN/, 'element-ui/lib/locale/lang/en')
  22. // ]
  23. resolve: {
  24. alias: {
  25. '@': resolve('src')
  26. }
  27. }
  28. },
  29. lintOnSave: false,
  30. devServer: {
  31. host: "0.0.0.0", //指定使用一个 host。默认是 localhost,这里默认值即可
  32. port: 8081, //指定端口
  33. hot: true, // 开启热更新
  34. https: false, // 是否开启https模式
  35. proxy: { // 请求代理服务器
  36. '/powerForecast': { //带上api前缀的
  37. // target: 'http://39.105.58.247:10880/powerForecast/', //代理目标地址
  38. target: 'http://127.0.0.1:10880/powerForecast/',
  39. changeOrigin: true,
  40. secure: false,
  41. pathRewrite: { // 在发出请求后将/api替换为''空值,这样不影响接口请求
  42. '^/powerForecast': ''
  43. }
  44. }
  45. }
  46. },
  47. chainWebpack(config) {
  48. config.module
  49. .rule('svg')
  50. .exclude.add(resolve('src/icons'))
  51. .end()
  52. config.module
  53. .rule('icons')
  54. .test(/\.svg$/)
  55. .include.add(resolve('src/icons'))
  56. .end()
  57. .use('svg-sprite-loader')
  58. .loader('svg-sprite-loader')
  59. .options({
  60. symbolId: 'icon-[name]'
  61. })
  62. .end()
  63. }
  64. }