vue.config.js 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. const proxy = {
  2. "/api/uq_basic": {
  3. target: process.env.VUE_APP_QUESTIONS_HOST_URL,
  4. changeOrigin: true,
  5. },
  6. };
  7. var webpack = require("webpack");
  8. var packageData = require("./package.json");
  9. var v = packageData.version;
  10. const timestamp = Date.now();
  11. let config = {
  12. // 这里设置项目的路径,比如 '/admin' 。设置以后 BASE_URL就有值了。
  13. // 注意这解决不了CDN的问题,CDN的问题要另行研究。
  14. // 可能的方案是另设一个替代 BASE_URL 的环境变量解决 <%%= BASE_URL %%>favicon.ico 和 ${process.env.BASE_URL}service-worker.js
  15. publicPath: "/admin",
  16. lintOnSave: process.env.NODE_ENV !== "production" ? true : "error",
  17. devServer: {
  18. proxy,
  19. // https://webpack.js.org/configuration/dev-server/#overlay
  20. client: {
  21. overlay: false,
  22. },
  23. },
  24. configureWebpack: {
  25. // devtool: "source-map", // for vscode debug
  26. plugins: [
  27. // Ignore all locale files of moment.js
  28. new webpack.IgnorePlugin({
  29. resourceRegExp: /^\.\/locale$/,
  30. contextRegExp: /moment$/,
  31. }),
  32. // new webpack.IgnorePlugin(/^\.\/locale$/, /moment$/),
  33. ],
  34. },
  35. transpileDependencies: [/\bvue-awesome\b/],
  36. productionSourceMap: false,
  37. };
  38. if (process.env.NODE_ENV === "production") {
  39. config.css = Object.assign(config.css || {}, {
  40. extract: {
  41. filename: `css/[name].${v}.${timestamp}.css`,
  42. chunkFilename: `css/[name].${v}.${timestamp}.css`,
  43. },
  44. });
  45. config.configureWebpack = Object.assign(config.configureWebpack || {}, {
  46. output: {
  47. filename: `js/[name].${v}.${timestamp}.js`,
  48. chunkFilename: `js/[name].${v}.${timestamp}.js`,
  49. },
  50. });
  51. }
  52. module.exports = config;
  53. require("events").EventEmitter.defaultMaxListeners = 0;