vue.config.js 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  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. changeOrigin: true,
  39. secure: false,
  40. pathRewrite: { // 在发出请求后将/api替换为''空值,这样不影响接口请求
  41. '^/powerForecast': ''
  42. }
  43. }
  44. }
  45. },
  46. chainWebpack(config) {
  47. config.module
  48. .rule('svg')
  49. .exclude.add(resolve('src/icons'))
  50. .end()
  51. config.module
  52. .rule('icons')
  53. .test(/\.svg$/)
  54. .include.add(resolve('src/icons'))
  55. .end()
  56. .use('svg-sprite-loader')
  57. .loader('svg-sprite-loader')
  58. .options({
  59. symbolId: 'icon-[name]'
  60. })
  61. .end()
  62. }
  63. }