vue.config.js 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. const packageName = require("./package.json").name;
  2. console.log(packageName);
  3. module.exports = {
  4. //路径前缀
  5. //打包配置,解决页面空白的配置方案。
  6. lintOnSave: true,
  7. runtimeCompiler: true,
  8. productionSourceMap: false,
  9. chainWebpack: (config) => {
  10. config.module
  11. .rule("fonts")
  12. .test(/.(ttf|otf|eot|woff|woff2)$/)
  13. .use("url-loader")
  14. .loader("url-loader")
  15. .tap((options) => {
  16. options = {
  17. // limit: 10000,
  18. name: "/static/fonts/[name].[ext]",
  19. };
  20. return options;
  21. });
  22. },
  23. // chainWebpack: (config) => {
  24. // 忽略的打包文件
  25. // config.externals({
  26. // 'vue': 'Vue',
  27. // 'vue-router': 'VueRouter',
  28. // 'vuex': 'Vuex',
  29. // 'axios': 'axios',
  30. // 'element-ui': 'ELEMENT',
  31. // });
  32. // const entry = config.entry('app');
  33. // entry.add('babel-polyfill').end();
  34. // entry.add('classlist-polyfill').end();
  35. // entry.add('@/mock').end();
  36. // },
  37. css: {
  38. extract: { ignoreOrder: true },
  39. },
  40. //开发模式反向代理配置,生产模式请使用Nginx部署并配置反向代理
  41. devServer: {
  42. port: 1777,
  43. headers: {
  44. "Access-Control-Allow-Origin": "*",
  45. },
  46. proxy: {
  47. "/api": {
  48. //本地服务接口地址
  49. target: "http://192.168.1.100/api",
  50. //远程演示服务地址,可用于直接启动项目
  51. //target: 'https://saber.bladex.vip/api',
  52. ws: true,
  53. pathRewrite: {
  54. "^/api": "/",
  55. },
  56. },
  57. },
  58. },
  59. // 自定义webpack配置
  60. configureWebpack: {
  61. output: {
  62. library: `${packageName}-[name]`,
  63. libraryTarget: "umd",
  64. jsonpFunction: `webpackJsonp_${packageName}`,
  65. },
  66. },
  67. };