vue.config.js 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  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://aidesign.nipponpaint.com.cn',//正式
  58. target: 'https://aidesigntest.nipponpaint.com.cn',//测试
  59. changeOrigin: true,
  60. secure: true
  61. },
  62. [process.env.VUE_APP_AIDESIGN_API]: {
  63. target: process.env.VUE_APP_AIDESIGN,
  64. changeOrigin: true,
  65. secure: false,
  66. pathRewrite: {
  67. ["^" + process.env.VUE_APP_AIDESIGN_API]: ""
  68. }
  69. },
  70. }
  71. }
  72. };