vue.config.js 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. const merge = require("webpack-merge");
  2. const tsImportPluginFactory = require("ts-import-plugin");
  3. const version = new Date().getTime() // 全局版本号
  4. module.exports = {
  5. publicPath: process.env.VUE_APP_publicPath,
  6. configureWebpack: {
  7. devtool: process.env.devtool,
  8. output: {
  9. filename: `static/js/[name].[hash:8].js`,
  10. chunkFilename: `static/js/[name].[hash:8].js`
  11. }
  12. },
  13. css: {
  14. extract: {
  15. filename: `static/css/[name].[hash:8].css`,
  16. chunkFilename: `static/css/[name].[hash:8].css`
  17. }
  18. },
  19. chainWebpack: config => {
  20. config.resolve.alias.set("@assets", "@/assets");
  21. config.module
  22. .rule("ts")
  23. .use("ts-loader")
  24. .tap(options => {
  25. options = merge(options, {
  26. transpileOnly: true,
  27. getCustomTransformers: () => ({
  28. before: [
  29. tsImportPluginFactory({
  30. libraryName: "vant",
  31. libraryDirectory: "es",
  32. style: true
  33. })
  34. ]
  35. })
  36. });
  37. return options;
  38. });
  39. config.plugin('html').tap(args => {
  40. args[0].meta = [
  41. { 'http-equiv': 'Cache-Control', content: 'no-cache, no-store, must-revalidate' },
  42. { 'http-equiv': 'Pragma', content: 'no-cache' },
  43. { 'http-equiv': 'Expires', content: '0' }
  44. ];
  45. args.forEach(arg => {
  46. arg.version = version
  47. })
  48. return args
  49. })
  50. },
  51. devServer: {
  52. // port: 8080,
  53. disableHostCheck: true, //放过域名检查
  54. open: true,
  55. proxy: {
  56. '/aidesign': {
  57. target: 'https://aidesigntest.nipponpaint.com.cn',//测试
  58. changeOrigin: true,
  59. secure: true
  60. },
  61. [process.env.VUE_APP_AIDESIGN_API]: {
  62. target: process.env.VUE_APP_AIDESIGN,
  63. changeOrigin: true,
  64. secure: false,
  65. pathRewrite: {
  66. ["^" + process.env.VUE_APP_AIDESIGN_API]: ""
  67. }
  68. },
  69. }
  70. }
  71. };