vue.config.js 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. const path = require("path");
  2. const HardSourceWebpackPlugin = require("hard-source-webpack-plugin");
  3. const AutoDllPlugin = require("autodll-webpack-plugin");
  4. function resolve(dir) {
  5. return path.join(__dirname, dir);
  6. }
  7. module.exports = {
  8. assetsDir: "./h5",
  9. publicPath: "./",
  10. outputDir: "cordova/www",
  11. configureWebpack: config => {
  12. Object.assign(config.resolve.alias, {
  13. "@utils": resolve("src/utils"),
  14. "@libs": resolve("src/libs"),
  15. "@api": resolve("src/api"),
  16. "@components": resolve("src/components"),
  17. "@assets": resolve("src/assets"),
  18. "@css": resolve("src/assets/css"),
  19. "@images": resolve("src/assets/images"),
  20. "@views": resolve("src/views"),
  21. "@mixins": resolve("src/mixins")
  22. });
  23. if (process.env.NODE_ENV !== "production") {
  24. config.plugins.push(
  25. new HardSourceWebpackPlugin(),
  26. new AutoDllPlugin({
  27. inject: true,
  28. debug: true,
  29. filename: "[name]_[hash].js",
  30. path: "./dll" + Date.parse(new Date()),
  31. entry: {
  32. vendor_vue: ["vue", "vuex", "vue-router"],
  33. vendor_ui: ["vue-awesome-swiper", "vue-ydui"],
  34. vendor_tools: ["axios", "core-js"]
  35. }
  36. })
  37. );
  38. }
  39. },
  40. chainWebpack: config => {
  41. config.plugin("html").tap(args => {
  42. args[0].VUE_APP_NAME = "美天旺";
  43. return args;
  44. });
  45. },
  46. // devServer: {
  47. // proxy: {
  48. // "/api": {
  49. // target: "http://twong.h/api", //代理地址,这里设置的地址会代替axios中设置的baseURL
  50. // changeOrigin: true, // 如果接口跨域,需要进行这个参数配置
  51. // }
  52. // }
  53. // },
  54. devServer: {
  55. proxy: {
  56. "/api": {
  57. target: "http://twong.h",
  58. changeOrigin: true
  59. }
  60. }
  61. }
  62. };